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")
}
}
import hudson.model.*
import org.jenkinsci.plugins.workflow.job.WorkflowJob
// For each project
for(item in Hudson.instance.items) {
// check that job is not building
if(!item.isBuilding() && !(item instanceof WorkflowJob))
{
println("Wiping out workspace of job "+item.name)
item.doDoWipeOutWorkspace()
}
else {
println("Skipping job "+item.name+", currently building")
}
}
def cleanupWorkspaceAsRoot() {
log.notice "Removing workspace contents: $WORKSPACE !"
docker.image('alpine').inside('-u root --env WORKSPACE') { // use docker instead of sudo // TODO make ALL docker builds work as non-ROOT, so there is no root-owned files
sh 'test -n "$WORKSPACE" && rm -rf "$WORKSPACE"/*'
}
}