Created
December 22, 2020 19:56
-
-
Save akostadinov/2380acfc5df3518ab5b99625734c52da to your computer and use it in GitHub Desktop.
Cancel all running Jenkins builds with system groovy script
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.Jenkins | |
def numCancels = 0; | |
Jenkins.instance.getAllItems(Job.class).each{ | |
def job = it | |
for (build in job.builds) { | |
if (build.isBuilding()) { build.doStop(); numCancels++; } | |
} | |
} | |
println("${numCancels}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment