我想将 Jenkins 构建标记为在一种情况下失败,例如:
if [ -f "$file" ]
then
echo "$file found."
else
echo "$file not found."
#Do Jenkins Build Fail
fi
可以通过 Shell 脚本实现吗?
答案:如果我们以整数 1 退出,Jenkins 构建将被标记为失败。因此我用 exit 1
替换了注释来解决这个问题。
请您参考如下方法:
您所需要做的就是退出 1。
if [ -f "$file" ]
then
echo "$file found."
else
echo "$file not found."
exit 1
fi