Forked from sytsereitsma/gist:1b370c558a4a34dfe014
Created
September 4, 2024 05:26
-
-
Save ferblape/4f94556befffb237ca4ae16b51911c47 to your computer and use it in GitHub Desktop.
[Jenkins] Clear build queue and cancel all builds
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
def q = Jenkins.instance.queue | |
q.items.findAll { q.cancel(it.task) } | |
//q.items.findAll { it.task.name.startsWith('my') }.each { q.cancel(it.task) } | |
def items = Jenkins.instance.items | |
items.each { job -> | |
job.builds.findAll { build -> build.building }.each { run -> | |
println("Aborting: " + job.name) | |
run.doStop(); | |
} | |
} | |
println("Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment