In the script console, run below script.
Reference
Reference
import jenkins.model.Jenkins import hudson.* import hudson.model.* import jenkins.* //Remove everything which is currently queued Jenkins.instance.queue.clear() def buildingJobs = Jenkins.instance.getAllItems(Job.class).findAll { it.isBuilding() } buildingJobs.each{ def jobName = it.toString() def val = jobName.split("\\[|\\]") //'Abort jobs' is the name of the job I have created, and I do not want it to abort itself. if((val[1].trim())!='Abort jobs'){ def job = Jenkins.instance.getItemByFullName(val[1].trim()) for (build in job.builds) { if (build.isBuilding()){ println(build) build.doStop(); } } } }
No comments:
Post a Comment