Skip to content

Instantly share code, notes, and snippets.

@shoelzle
Last active December 24, 2020 07:53
Show Gist options
  • Save shoelzle/d46c9e6cc621eda33368af7978de8404 to your computer and use it in GitHub Desktop.
Save shoelzle/d46c9e6cc621eda33368af7978de8404 to your computer and use it in GitHub Desktop.
Jenkins script: abort stuck build
// Execute this script in the Jenkins script console
def jobname = "some-job-name"
def buildnum = 99
def job = Jenkins.instance.getItemByFullName(jobname)
for (build in job.builds) {
if (buildnum == build.getNumber().toInteger()){
if (build.isBuilding()){
build.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment