Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: Is there any way to cleanup Jenkins workspace?

How can I cleanup the workspace in Jenkins? I am using AccuRev as version control tool.

I created freestyle projects in Jenkins.

like image 296
Karthik Avatar asked Sep 26 '22 05:09

Karthik


People also ask

How do I clean up Jenkins workspace?

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.

Does Jenkins automatically clean workspace?

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.

How do you clear the workspace in Jenkins pipeline?

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.

Can we delete the workspace in Jenkins?

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.

What is the best way to clean Jenkins workspace?

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.

Why does Jenkins delete the job configuration of a job?

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.

How do I automate a Jenkins job?

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).

How do I clean up the workspace after a build?

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.


1 Answers

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.

like image 118
Nagendra Singh Avatar answered Oct 09 '22 15:10

Nagendra Singh