Jenkins tricks¶
Kill stacked job¶
Sometimes Jenkins job could stack without response, and can't be killed from the UI. Go to Manage Jenkins -> Script Console and paste there one of these code-blocks. Change job name and build number to relevant ones and run it.
Jenkins.instance.getItemByFullName("CI/rc-preprod")
.getBuildByNumber(895)
.finish(
hudson.model.Result.ABORTED,
new java.io.IOException("Aborting build")
);
or
def jobname = "CI/rc-preprod"
def buildnum = 895
def job = Jenkins.instance.getItemByFullName(jobname)
for (build in job.builds) {
if (buildnum == build.getNumber().toInteger()){
if (build.isBuilding()){
build.doStop();
build.doKill();
}
}
}