For those that are interested, I solved the issue by writing a small Groovy script that gets executed periodically. This script goes through the online slaves, list the content of their workspaces and delete any subdirectories whose name does not match any existing job configuration. It must be executed on the master node (apparently slaves do not have access to job configuration - which seems normal).
The script is available at http://snipt.org/ujhhd4. Unfortunately, only the slaves that are online at the time the script is executed are cleaned up... Ideally, the script should also be executed when a slave connects. For that reason, I'm thinking about writing a java plugin for Jenkins that would handle the cleanup. -----Original Message----- From: jenkinsci-users@googlegroups.com [mailto:jenkinsci-users@googlegroups.com] On Behalf Of Simon Wiest Sent: mercredi 16 mai 2012 15:01 To: jenkinsci-users@googlegroups.com Subject: Re: Workspace cleanup after job removal Hi Bertrand, Jenkins does not explicitly delete the workspace of a job when deleting the job. But if your job happens to reside on the master and your workspace happens to reside within your job directory (this is the default), deleting the job will also remove its workspace implicitly. If your workspace resides on a slave or outside your job directory, Jenkins will not delete it. I guess, this would be also tricky to implement: First, it would require Jenkins to keep a list of all slaves that have ever built that very job. Second, a slave might be off-line during job removal. What would happen with the workspace on this slave then? Will it be deleted, when the slave comes on-line again? Sorry, no extended magic here - yet ;O). Cheers, Simon.