8

I have inherited a Jenkins server and need to clear some space. I have set a;

post {
   always {
     deleteDir()
   }
 }

on all the jobs. Can I remove old builds safely by deleting the contents of workspace and jobs in the $JENKINS_HOME?

6

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.

You can also use the Workspace Cleaner Plugin in order to delete workspace content before the beginning of a job run.

In addition, you can set a "Post Build Action" in your jobs which is called "Delete workspace when build is done".

You can find more information in this nice blog post.

| improve this answer | |
  • I've edited my answer to include more information. – Itai Ganot Nov 23 '17 at 15:37
1

Maybe it depends on your Jenkins version, but its not safe to remove everything from the jobs directory, as I just learned the hard way this deletes all your jobs after you restart Jenkins.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.