使用shell脚本在Jenkins中手动构建失败

Sel*_*amy 51 shell continuous-integration jenkins

我想在一个场景上标记Jenkins构建失败,例如:

if [ -f "$file" ]
then
    echo "$file found."
else
    echo "$file not found."
    #Do Jenkins Build Fail
fi
Run Code Online (Sandbox Code Playgroud)

是否可以通过Shell脚本?

答:如果我们以整数1退出,Jenkins构建将被标记为失败.所以我替换了评论exit 1来解决这个问题.

alk*_*ion 76

您需要做的就是退出1.

if [ -f "$file" ]
then
    echo "$file found."
else
    echo "$file not found."
    exit 1
fi
Run Code Online (Sandbox Code Playgroud)

  • 您可以添加解释此文档的文档的链接吗?谢谢你的回答顺便说一下. (3认同)