Workspace cleanup after job removal

5,329 views
Skip to first unread message

Bertrand Renuart

unread,
May 14, 2012, 10:44:53 AM5/14/12
to jenkins...@googlegroups.com

Dear all,

 

After some investigations, it appears Jenkins doesn’t cleanup a job’s (latest) workspace after the corresponding job definition is removed.

Is it on purpose or is there any configuration parameter I could tweak to enable such workspace garbage collection ?

 

Thanks for your advices,

 

/Bertrand

 

Jan Seidel

unread,
May 16, 2012, 4:21:27 AM5/16/12
to jenkins...@googlegroups.com
Hi Bertrand,

I am a bit confused. Are you talking about DELETING the job itself and the workspace remains or after spawning a build job?
If you delete a job in Jenkins should everything be gone.
There is a plugin called Jenkins Workspace Cleanup Plugin to clean the workspace before or after a build job.

Take care
Jan

Bertrand Renuart

unread,
May 16, 2012, 7:02:42 AM5/16/12
to jenkins...@googlegroups.com

I’m talking about DELETING the job through the UI on master.

In this case, the corresponding workspace remains on our single slave.

Jan Seidel

unread,
May 16, 2012, 8:26:53 AM5/16/12
to jenkins...@googlegroups.com
Weird.

I know only about this issue if more than one workspace is available.

Simon Wiest

unread,
May 16, 2012, 9:00:31 AM5/16/12
to jenkins...@googlegroups.com
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.
--
Jan Seidel (16.05.2012 14:26):
> Weird.
>
> I know only about this issue if more than one workspace is available.
>
> Am Mittwoch, 16. Mai 2012 13:02:42 UTC+2 schrieb Bertrand Renuart:
>
> I’m talking about DELETING the job through the UI on master.
>
> In this case, the corresponding workspace remains on our single slave.
>
> *From:*jenkins...@googlegroups.com
> <mailto:jenkins...@googlegroups.com>
> [mailto:jenkins...@googlegroups.com
> <mailto:jenkins...@googlegroups.com>] *On Behalf Of *Jan Seidel
> *Sent:* mercredi 16 mai 2012 10:21
> *To:* jenkins...@googlegroups.com
> <mailto:jenkins...@googlegroups.com>
> *Subject:* Re: Workspace cleanup after job removal
>
> Hi Bertrand,
>
> I am a bit confused. Are you talking about DELETING the job itself
> and the workspace remains or after spawning a build job?
> If you delete a job in Jenkins should everything be gone.
> There is a plugin called Jenkins Workspace Cleanup Plugin
> <http://updates.jenkins-ci.org/download/plugins/ws-cleanup/> to

Bertrand Renuart

unread,
May 30, 2012, 6:01:38 AM5/30/12
to jenkins...@googlegroups.com
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: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com] On Behalf Of Simon Wiest
Sent: mercredi 16 mai 2012 15:01
To: jenkins...@googlegroups.com
Subject: Re: Workspace cleanup after job removal

Hi Bertrand,

Kamal Ahmed

unread,
May 30, 2012, 11:39:39 PM5/30/12
to jenkins...@googlegroups.com
Well,
I removed jenkins via ' apt-get remove jenkins
then manually removed /etc/init.d/jenkins

Now when i install Jenkins  via qpt-get install jenkins, it does not restore the /etc/init.d/jenkins file back.

Any suggestions ?
Thanks,
-Kamal.

Barış İnanç

unread,
May 31, 2012, 4:20:25 AM5/31/12
to jenkins...@googlegroups.com
If you delete with apt get remove jenkins --purge parameters all files should be removed from your computer. Then you can install with apt get install jenkins command. Then I think stratup script should be emerge

2012/5/31 Kamal Ahmed <kamal22...@yahoo.com>



--
Barış İNANÇ
Yeditepe Üniversitesi
Bilgisayar Mühendisliği

Mark Waite

unread,
May 31, 2012, 7:14:02 AM5/31/12
to jenkins...@googlegroups.com
You may need to remove configuration files[1] in order to persuade apt-get install that the package has been completely removed, before installing again.

Mark Waite



From: Kamal Ahmed <kamal22...@yahoo.com>
To: "jenkins...@googlegroups.com" <jenkins...@googlegroups.com>
Sent: Wednesday, May 30, 2012 9:39 PM
Subject: /etc/init.d/jenkins missing

Antti Kaihola

unread,
Nov 20, 2015, 2:36:36 AM11/20/15
to Jenkins Users, bertrand...@modulo1.be

Frederic Meyrou

unread,
Mar 3, 2016, 9:08:23 AM3/3/16
to Jenkins Users, bertrand...@modulo1.be
Hi Bertrand,

Would you mind to share your script again please?

./Frédéric
Reply all
Reply to author
Forward
0 new messages