Created
February 10, 2025 09:58
-
-
Save linuxoid69/e2bc37d6f1fa8002a81ac934bfbb7db0 to your computer and use it in GitHub Desktop.
[Jenkins] stop all running jobs in multibranch
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
import hudson.model.* | |
// get all running jobs | |
Jenkins.instance.getAllItems(AbstractItem.class).each { item -> | |
if (item instanceof org.jenkinsci.plugins.workflow.job.WorkflowJob && item.fullName.contains("your-job")) { | |
item.builds.each { build -> | |
if (build.isBuilding()) { | |
println "Stopping build: ${build.fullDisplayName}" | |
build.doStop() // stop running job | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment