How to stop a build in Jenkins via the REST api ?

If the build has started, by POST on:

http://<Jenkins_URL>/job/<Job_Name>/<Build_Number>/stop

Will stop/cancel the current build.

If the build has not started, you have the queueItem, then POST on:

http://<Jenkins_URL>/queue/cancelItem?id=<queueItem>

This is assuming your Jenkins Server has not been secured, otherwise you need to add BASIC authentication for a user with Cancel privileges.

Leave a Comment