Forked from jmarcos-cano/kill-jenkins-stuck-build.groovy
Last active
December 24, 2020 07:53
-
-
Save shoelzle/1bb97c1361d1ce14d66c91273ff0a95d to your computer and use it in GitHub Desktop.
Jenkins script: stop & kill 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 = "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