使用 shell 脚本在 Jenkins 中手动构建是否失败 [英] Do manual build fail in Jenkins using shell script
本文介绍了使用 shell 脚本在 Jenkins 中手动构建是否失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将 Jenkins 构建标记为在一种情况下失败,例如:
I would like to mark a Jenkins build to fail on one scenario for example:
if [ -f "$file" ]
then
echo "$file found."
else
echo "$file not found."
#Do Jenkins Build Fail
fi
可以通过 Shell 脚本实现吗?
Is it possible via Shell Script?
答案:如果我们以整数 1 退出,Jenkins 构建将被标记为失败.所以我用 exit 1
替换了注释来解决这个问题.
Answer: If we exit with integer 1, Jenkins build will be marked as failed. So I replaced the comment with exit 1
to resolve this.
推荐答案
你需要做的就是退出1.
All you need to do is exit 1.
if [ -f "$file" ]
then
echo "$file found."
else
echo "$file not found."
exit 1
fi
这篇关于使用 shell 脚本在 Jenkins 中手动构建是否失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文