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

2024-04-27

我想将 Jenkins 构建标记为在一种情况下失败,例如:

if [ -f "$file" ]
then
    echo "$file found."
else
    echo "$file not found."
    #Do Jenkins Build Fail
fi

可以通过Shell脚本实现吗?

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


您只需从 1 号出口退出即可。

if [ -f "$file" ]
then
    echo "$file found."
else
    echo "$file not found."
    exit 1
fi
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 shell 脚本在 Jenkins 中手动构建失败吗 的相关文章

随机推荐