Pranav Kumar
Pranav Kumar

Reputation: 333

Jenkins is deleting workspaces on agents

Jenkins is deleting workspaces on agents/nodes after 30 days or 30th day of month. After looking into jenkins folder located at

/var/lib/jenkins/logs/tasks

I found logs here with name Workspace\ clean-up.log. Why this is being created? I suspected it may be because of workspace cleanup plugin. Now I have deleted this plugin as well, but this issue is not resolved. How to know why workspaces are getting deleted on agents? Is there a way i can stop this?

Upvotes: 4

Views: 4233

Answers (1)

Ian W
Ian W

Reputation: 4767

Refer to Jenkins Features Controlled with System Properties

  • hudson.model.WorkspaceCleanupThread.disabled [ false ] Don't clean up old workspaces on agent nodes

  • hudson.model.WorkspaceCleanupThread.recurrencePeriodHours [ 24 ] How often workspace cleanup should run, in hours.

  • hudson.model.WorkspaceCleanupThread.retainForDays [ 30 ] Unused workspaces are retained for this many days before qualifying for deletion

If you have more than one node and jobs can float across nodes, you really want them cleaned up.

The order of parameters in the startup command is important, but basically these options belong at the end.

Refer to: RPM launcher or Docker launcher

It becomes: $JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR $JENKINS_PARAMS

UPDATE: As of LTS 222.1(ref. to Changelog notes), Jenkins introduced a global build discarder default. It's worth reading Cloudbee's - Best Strategy for Disk Space Management: Clean Up Old Builds

Upvotes: 6

Related Questions