Skip to content

Instantly share code, notes, and snippets.

@bchetty
Last active June 28, 2016 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bchetty/132d442e0675b4774a3e698661a2d344 to your computer and use it in GitHub Desktop.
Save bchetty/132d442e0675b4774a3e698661a2d344 to your computer and use it in GitHub Desktop.
Cleanup workspace of all jobs in Jenkins - Ref: https://wiki.jenkins-ci.org/display/JENKINS/Wipe+out+workspaces+of+all+jobs
import hudson.model.*
// For each project
for(item in Hudson.instance.items) {
// check that job is not building
if(!item.isBuilding()) {
println("Wiping out workspace of job "+item.name)
item.doDoWipeOutWorkspace()
}
else {
println("Skipping job "+item.name+", currently building")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment