如果执行 shell 失败,不要让 jenkins 构建失败
问题描述:
作为构建过程的一部分,我将 git commit 作为执行 shell 步骤运行.但是,如果工作区中没有变化,Jenkins 将导致构建失败.这是因为 git 在没有要提交的更改时返回错误代码.如果是这种情况,我想中止构建,或者只是将其标记为不稳定.有什么想法吗?
As part of my build process, I am running a git commit as an execute shell step. However, if there are no changes in the workspace, Jenkins is failing the build. This is because git is returning an error code when there are no changes to commit. I'd like to either abort the build, or just mark it as unstable if this is the case. Any ideas?
答
当命令失败时停止进一步执行:
To stop further execution when command fails:
命令 ||退出0
在命令失败时继续执行:
命令 ||真实