Created
March 9, 2018 12:36
-
-
Save andrewdmcleod/133640092f9a0252a69c125e8ae31d06 to your computer and use it in GitHub Desktop.
pipeline groovy - search and destroy jenkins job
This file contains 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
import jenkins.model.* | |
import hudson.model.* | |
def jobName = "${JOB_NAME}" | |
Jenkins.instance.getAllItems(AbstractItem.class).each { | |
job-> | |
job.builds.each { build-> | |
if (build.getResult().equals(null)) { | |
buildname = build.toString() | |
if (buildname.contains(jobName)) { | |
println("Killing job: " + buildname) | |
build.doStop(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment