Linux – don’t fail jenkins build if execute shell fails

Jenkinslinuxunix

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?

Best Answer

To stop further execution when command fails:

command || exit 0

To continue execution when command fails:

command || true