Cleaning up workspaces of old jobs on slaves

51 views
Skip to first unread message

Philippe Cadé

unread,
Feb 23, 2016, 12:15:35 PM2/23/16
to Jenkins Users
Hi,

I would like to automatically clean the workspace on slaves since our slaves run out of disk space from time to time.

I saw that there are plugins to clean a job's workspace before or after the execution and I've seem this groovy script but I'm not really satisfied with those solutions. I would like to only delete a few of the last used workspaces that would bring me back within the free disk space threshold that we've defined. Not delete the whole thing to keep things fast.

For this I'm thinking about using the last access property on the workspace, however this doesn't seem to be available from the Jenkins API.

So I came to the conclusion that a plugin would be the way to do this and before I start building my own I hope that someone can point to an existing solution.

Thanks
Philippe

Victor Martinez

unread,
Feb 24, 2016, 6:02:51 PM2/24/16
to Jenkins Users
Have you considered to use http://javadoc.jenkins-ci.org/hudson/model/WorkspaceCleanupThread.html? Although I have not used it yet, since I've just found it

You can configure it based on the following properties:

hudson.model.WorkspaceCleanupThread.disabledfalse Don't clean up old workspaces on slave nodes
hudson.model.WorkspaceCleanupThread.recurrencePeriodHours241.608How often workspace cleanup should run, in hours.
hudson.model.WorkspaceCleanupThread.retainForDays301.608Unused workspaces are retained for this many days before qualifying for deletion.
Further details:
Reply all
Reply to author
Forward
0 new messages