How can I cleanup the workspace in Jenkins? I am using AccuRev as version control tool.
I created freestyle projects in Jenkins.
not allowed to comment, therefore:
The answer from Upen works just fine, but not if you have Jenkins Pipeline Jobs mixed with Freestyle Jobs. There is no such Method as DoWipeWorkspace on Pipeline Jobs. So I modified the Script in order to skip those:
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")
}
}
you could also filter by Job Names if required:
item.getDisplayName().toLowerCase().contains("release")