Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shoelzle/1bb97c1361d1ce14d66c91273ff0a95d to your computer and use it in GitHub Desktop.
Save shoelzle/1bb97c1361d1ce14d66c91273ff0a95d to your computer and use it in GitHub Desktop.
Jenkins script: stop & kill stuck build
// Execute this script in the Jenkins script console
def jobname = "the-job-name"
def buildnum = 85
def job = Jenkins.instance.getItemByFullName(jobname)
for (build in job.builds) {
if (buildnum == build.getNumber().toInteger()) {
if (build.isBuilding()){
build.doStop();
build.doKill();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment