Reputation: 8685
I clicked on execute shell 3 times and have 3 shell scripts that jenkins runs during a build. How do I end a job mid build in one of the scripts?
I tried exit
but that only ends the particular script and not the job.
Upvotes: 0
Views: 4742
Reputation: 111623
If you click on the (?) help icon next to the "Execute Shell" field in your job configuration, you'll see that it says:
the build is considered a failure if any of the commands exits with a non-zero exit code.
Therefore, if you detect that you want to stop the build from a shell script, you can use exit 1
(to signify failure) rather than just calling exit
, which is equivalent to exit 0
(which signifies success).
This will stop the build immediately, marking it as a failure — no other build steps will be executed.
Upvotes: 4