don't fail jenkins build if execute shell fails

前端 未结 14 1246
无人共我
无人共我 2020-12-04 08:08

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 be

14条回答
  •  无人及你
    2020-12-04 08:49

    If there is nothing to push git returns exit status 1. Execute shell build step is marked as failed respectively. You can use OR statement || (double pipe).

    git commit -m 'some messasge' || echo 'Commit failed. There is probably nothing to commit.'
    

    That means, execute second argument if first failed (returned exit status > 0). Second command always returns 0. When there is nothing to push (exit status 1 -> execute second command) echo will return 0 and build step continues.

    To mark build as unstable you can use post-build step Jenkins Text Finder. It can go through console output, match pattern (your echo) and mark build as unstable.

提交回复
热议问题