Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to abort Jenkins build from shell script?

Tags:

jenkins

I see that returning a non-zero integer in shell script executing on Jenkins will make the result marked as a failure.

How do I make it change to Aborted? Is there a plugin to do this? Can I avoid having to use GroovyScript?

like image 846
Lucky Avatar asked Jun 11 '17 08:06

Lucky


People also ask

How do you abort a Jenkins build?

BUILD ID URL/stop - aborts a Pipeline. BUILD ID URL/term - forcibly terminates a build (should only be used if stop does not work). BUILD ID URL/kill - hard kill a pipeline.

How do you abort Jenkins job forcefully?

Abort the job by clicking the red X next to the build progress bar. Click on "Pause/resume" on the build to pause. Click on "Pause/resume" again to resume the build.


1 Answers

Instead of returning a non-zero integer and having the build fail, you could trigger an Abort on the build using its Rest API within the shell build step.

Example using curl:

curl -XPOST $BUILD_URL/stop

Example using wget:

wget --post-data="" $BUILD_URL/stop
like image 144
clipitar Avatar answered Oct 05 '22 14:10

clipitar