Last active
December 24, 2020 07:53
-
-
Save shoelzle/d46c9e6cc621eda33368af7978de8404 to your computer and use it in GitHub Desktop.
Jenkins script: abort stuck build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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