Quantcast

CLI option /Groovy script to wipe out work space

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

CLI option /Groovy script to wipe out work space

BK-2
Hi,

We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs.  I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!

Thanks in Advance
BK.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

Vojtech Juranek
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

BK-2
Thanks Vjuranek.
Yes, we use Workspace cleanup plugin but I was looking for some scripted way to wipe out workspace for number for jobs in one go.
I will give a try to build.getWorkspace().deleteRecursive() .


On Thursday, August 30, 2012 7:42:11 PM UTC+1, vjuranek wrote:
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="DeIrttiWGFYJ">bhushan....@...>
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DeIrttiWGFYJ">jenkin...@...
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

BK-2

I have tested simple groovy script  as below,

 def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").getWorkspace().deleteRecursive()

But their is difference in behavior of   WipeOut workspace option on Jenkins and above script.

My groovy script removes all the files from workspace but not reference to Clearcase View. (P.S Clear case view is at different location)
whereas Jenkins Wipe out workspace removes all the references to workspace. It removes clearcase view present under different location.

On Thursday, August 30, 2012 8:04:05 PM UTC+1, BK wrote:
Thanks Vjuranek.
Yes, we use Workspace cleanup plugin but I was looking for some scripted way to wipe out workspace for number for jobs in one go.
I will give a try to build.getWorkspace().deleteRecursive() .


On Thursday, August 30, 2012 7:42:11 PM UTC+1, vjuranek wrote:
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

cjo9900
If you want the SCM to remove the clearcase view
you will need to have the SCM process the workspace before deletion, you will need to get the SCM and call processWorkspaceBeforeDeletion() on it [1]

so from the project object call getScm() [2], then call that with processWorkspaceBeforeDeletion()
which should remove the view for that workspace.


[2] http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getScm()



On Friday, August 31, 2012 10:50:18 AM UTC+1, BK wrote:

I have tested simple groovy script  as below,

 def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").getWorkspace().deleteRecursive()

But their is difference in behavior of   WipeOut workspace option on Jenkins and above script.

My groovy script removes all the files from workspace but not reference to Clearcase View. (P.S Clear case view is at different location)
whereas Jenkins Wipe out workspace removes all the references to workspace. It removes clearcase view present under different location.

On Thursday, August 30, 2012 8:04:05 PM UTC+1, BK wrote:
Thanks Vjuranek.
Yes, we use Workspace cleanup plugin but I was looking for some scripted way to wipe out workspace for number for jobs in one go.
I will give a try to build.getWorkspace().deleteRecursive() .


On Thursday, August 30, 2012 7:42:11 PM UTC+1, vjuranek wrote:
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

vlatombe
You should call 
def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").doWipeOutWorkspace()
it will perform the same action as clicking on the link in the UI.

Vincent


2012/8/31 cjo <[hidden email]>
If you want the SCM to remove the clearcase view
you will need to have the SCM process the workspace before deletion, you will need to get the SCM and call processWorkspaceBeforeDeletion() on it [1]

so from the project object call getScm() [2], then call that with processWorkspaceBeforeDeletion()
which should remove the view for that workspace.


[2] http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getScm()




On Friday, August 31, 2012 10:50:18 AM UTC+1, BK wrote:

I have tested simple groovy script  as below,

 def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").getWorkspace().deleteRecursive()

But their is difference in behavior of   WipeOut workspace option on Jenkins and above script.

My groovy script removes all the files from workspace but not reference to Clearcase View. (P.S Clear case view is at different location)
whereas Jenkins Wipe out workspace removes all the references to workspace. It removes clearcase view present under different location.

On Thursday, August 30, 2012 8:04:05 PM UTC+1, BK wrote:
Thanks Vjuranek.
Yes, we use Workspace cleanup plugin but I was looking for some scripted way to wipe out workspace for number for jobs in one go.
I will give a try to build.getWorkspace().deleteRecursive() .


On Thursday, August 30, 2012 7:42:11 PM UTC+1, vjuranek wrote:
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

BK-2
Thanks Vincent that worked!!

On Friday, August 31, 2012 3:24:29 PM UTC+1, Vincent Latombe wrote:
You should call 
def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").doWipeOutWorkspace()
it will perform the same action as clicking on the link in the UI.

Vincent


2012/8/31 cjo <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lVH-u0hMYV0J">cjo.j...@...>
If you want the SCM to remove the clearcase view
you will need to have the SCM process the workspace before deletion, you will need to get the SCM and call processWorkspaceBeforeDeletion() on it [1]

so from the project object call getScm() [2], then call that with processWorkspaceBeforeDeletion()
which should remove the view for that workspace.


[2] http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getScm()




On Friday, August 31, 2012 10:50:18 AM UTC+1, BK wrote:

I have tested simple groovy script  as below,

 def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").getWorkspace().deleteRecursive()

But their is difference in behavior of   WipeOut workspace option on Jenkins and above script.

My groovy script removes all the files from workspace but not reference to Clearcase View. (P.S Clear case view is at different location)
whereas Jenkins Wipe out workspace removes all the references to workspace. It removes clearcase view present under different location.

On Thursday, August 30, 2012 8:04:05 PM UTC+1, BK wrote:
Thanks Vjuranek.
Yes, we use Workspace cleanup plugin but I was looking for some scripted way to wipe out workspace for number for jobs in one go.
I will give a try to build.getWorkspace().deleteRecursive() .


On Thursday, August 30, 2012 7:42:11 PM UTC+1, vjuranek wrote:
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: CLI option /Groovy script to wipe out work space

BK-2
Actually I had to make small tweak in the method name as below,

def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").doDoWipeOutWorkspace()

On Monday, September 3, 2012 11:02:53 AM UTC+1, BK wrote:
Thanks Vincent that worked!!

On Friday, August 31, 2012 3:24:29 PM UTC+1, Vincent Latombe wrote:
You should call 
def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").doWipeOutWorkspace()
it will perform the same action as clicking on the link in the UI.

Vincent


2012/8/31 cjo <[hidden email]>
If you want the SCM to remove the clearcase view
you will need to have the SCM process the workspace before deletion, you will need to get the SCM and call processWorkspaceBeforeDeletion() on it [1]

so from the project object call getScm() [2], then call that with processWorkspaceBeforeDeletion()
which should remove the view for that workspace.


[2] http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getScm()




On Friday, August 31, 2012 10:50:18 AM UTC+1, BK wrote:

I have tested simple groovy script  as below,

 def hi = hudson.model.Hudson.instance
           hi.getItemByFullName("JobName").getWorkspace().deleteRecursive()

But their is difference in behavior of   WipeOut workspace option on Jenkins and above script.

My groovy script removes all the files from workspace but not reference to Clearcase View. (P.S Clear case view is at different location)
whereas Jenkins Wipe out workspace removes all the references to workspace. It removes clearcase view present under different location.

On Thursday, August 30, 2012 8:04:05 PM UTC+1, BK wrote:
Thanks Vjuranek.
Yes, we use Workspace cleanup plugin but I was looking for some scripted way to wipe out workspace for number for jobs in one go.
I will give a try to build.getWorkspace().deleteRecursive() .


On Thursday, August 30, 2012 7:42:11 PM UTC+1, vjuranek wrote:
Hi,
what about Workspace cleanup plugin [1] or Distributed workspace clean plugin [2]?
If you are searching for a function how to delete workspace, it's build.getWorkspace().deleteRecursive()

HTH
Vojta

[1] https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Hudson+Distributed+Workspace+Clean+plugin

----- Original Message -----
From: "BK" <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2012 5:52:46 PM
Subject: CLI option /Groovy script to wipe out work space

Hi,


We have single Jenkins Master hosting number of Jobs.It is very laborious to use Jenkins console to wipe out workspace from Jobs. I am looking for automated way to wipe out workspace.
I have explored Jenkins CLI but it does not contain any command for deletion of workspace.I was trying to put together a groovy script to delete the workspace but could not find appropriate functions in Jenkins API . has anyone faced similar issue ? Please help !!


Thanks in Advance
BK.

Loading...