13

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?

2 Answers 2

11

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.

0
4

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.

2
  • Can you share any more detail on what you deleted and how the app responded once restarted?
    – trebor
    Aug 13 at 23:44
  • It has been a while, but from what I remember I deleted everything in the jobs folder, also the XML files. This resulted in all the jobs being removed and Jenkins was basically empty. We had to recover Jenkins from a backup, so be careful and start with making a full backup.
    – Derek Smit
    Aug 24 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .