Created
October 11, 2022 07:55
-
-
Save devromans/77eb763b44de1675778178f7d0cc9a18 to your computer and use it in GitHub Desktop.
Jenkins Groovy snippets
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
for(job in jenkins.model.Jenkins.theInstance.getAllItems()) { | |
println "\nJob: $job.name" | |
job.delete() | |
} |
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
jenkins.model.Jenkins.theInstance.getView("WORKERS").items.each { job -> | |
println "\nJob: $job.name" | |
job.disabled = true | |
} |
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
MAX_BUILDS = 1 | |
for (job in Jenkins.instance.items) { | |
def recent = job.builds.limit(MAX_BUILDS) | |
for (build in job.builds) { | |
if (!recent.contains(build)) { | |
build.delete() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment