How can I cleanup the workspace in Jenkins? I am using AccuRev
as version control tool.
I created freestyle
projects in Jenkins.
You will need to install this plugin before the options mentioned above will appear
Workspace Cleanup Plugin
This plugin add the check box to all job configs to allow you to delete the whole workspace before any steps (inc source control) are run
This is useful to make sure you always start from a known point to guarantee how you build will run
There is a way to cleanup workspace in Jenkins. You can clean up the workspace before build or after build.
First, install Workspace Cleanup Plugin.
To clean up the workspace before build: Under Build Environment, check the box that says Delete workspace before build starts.
To clean up the workspace after the build: Under the heading Post-build Actions select Delete workspace when build is done from the Add Post-build Actions drop down menu.
Workspace Cleanup Plugin
In Jenkins file add
cleanWs()
This will delete the workspace after the build is complete
If you want to manually clean it up, for me with my version of jenkins (didn't appear to need an extra plugin installed, but who knows), there is a "workspace" link on the left column, click on your project, then on "workspace", then a "Wipe out current workspace" link appears beneath it on the left hand side column.
If you want to just remove one dir (or file) you can use Groovy and Manage Jenkins → Scripts Console run a script which removes it.
For example, you can look at the files with:
dh = new File('./bitnami/jenkins/jenkins_home/workspace/jobname/folder')
dh.eachFile {
println(it)
}
And then, when you have the folder you want to delete in dh
, you could simply append the next code:
dh.deleteDir()
And it will be deleted.
Note: The path shown in the example is for a Bitnami Jenkins installation, yours could be different.