Skip to content

Instantly share code, notes, and snippets.

@DSdatsme
Last active May 25, 2021 12:58
Show Gist options
  • Save DSdatsme/027511850220866a3a1d20022191c802 to your computer and use it in GitHub Desktop.
Save DSdatsme/027511850220866a3a1d20022191c802 to your computer and use it in GitHub Desktop.
Stop a Jenkins job forcefully
Jenkins.instance.getItemByFullName("FULL_JOB_PATH").getBuildByNumber(BUILD_NUMBER).finish(
hudson.model.Result.ABORTED,
new java.io.IOException("Aborting build"));
/*
To run the above line, navigate to:
Jenkins homepage -> Manage Jenkins -> Script Console
OR
open https://<jenkins domain>/script
BUILD_NUMBER [Integer] = is the vault of the build you want to abort
FULL_JOB_PATH [String] = is the path to job. You can find it from the job URL as follows.
JENKINS URL:-
https://jenkins.example.com/job/FOLDER_NAME/job/JOB_NAME/32
HERE
BUILD_NUMBER = 32
FULL_JOB_PATH = "FOLDER_NAME/JOB_NAME"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment