How can I cleanup the workspace in Jenkins? I am using AccuRev
as version control tool.
I created freestyle
projects in Jenkins.
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.
Now you can configure an existing job in Jenkins to use the Cleanup job you just created. Open Configuration of an existing job and add a post-build action to trigger the above created new clean-up job. So, after Job A executes and builds, Job B (clean up its own workspace) will run automatically.
Login to Jenkins, click on “Manage Jenkins” > “Manage Plugins” > Click on the “Available” tab then search for “workspace cleanup“. You will see various plugins listed. Click on the checkbox for “Workspace Cleanup“, plugin then click on install without reboot tab below the page.
Yes, you can delete the workspaces safely as well as jobs. The idea of the jobs directory is to allow you to display jobs history, if job history is not important for you then you can delete job directories from there.
Persist only the latest 3 or 5 folders (sorted by date modified) in the workspace or by Sprint numbers (latest 3 or 5 folders based on sprint number) and remove the rest after every successful build. Also to create a nightly job to do the automatic cleanup for all jobs in Jenkins.
Problem is, if you have subfolders of jobs in Jenkins (like I did) the script will delete the JOB configuration, and not the build files. It wiped out multiple job configurations and we had to pull from backups to recreate them. ONLY use the UI/BuildDiscarder plugins and options to clean up the Master node.
So, after Job A executes and builds, Job B (clean up its own workspace) will run automatically. You can automate this job for all the jobs in Jenkins as a nightly job. To do this, create a build-trigger to run at a certain time every week. Note: (Only configure this for either of b or d scenarios mentioned above).
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 Actionsselect Delete workspace when build is donefrom the Add Post-build Actionsdrop down menu.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With