Is there a way to make "discard old builds" happen right now?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a way to make "discard old builds" happen right now?

jdhein
My organization has just tons of projects in Jenkins, many of which
are not active and have not built in some time, some of them haven't
built in over 17 months. I have gone through and turned on "discard
old builds" with a max of 10 builds. However, it has been weeks since
changing this setting and Jenkins has not deleted the excess builds. I
am guessing I have to poke the bear by kicking off a build... only, I
don't want to do this for projects I am not directly involved with.

Is there a way to tell Jenkins to go ahead and discard the old builds
right now?
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

Christopher Orr
On 06/10/11 21:19, jdhein wrote:

> My organization has just tons of projects in Jenkins, many of which
> are not active and have not built in some time, some of them haven't
> built in over 17 months. I have gone through and turned on "discard
> old builds" with a max of 10 builds. However, it has been weeks since
> changing this setting and Jenkins has not deleted the excess builds. I
> am guessing I have to poke the bear by kicking off a build... only, I
> don't want to do this for projects I am not directly involved with.
>
> Is there a way to tell Jenkins to go ahead and discard the old builds
> right now?

You can use the Script Console to fetch the jobs you want, and then call
logRotate() on each of them.

Probably something like this should work, not that I've tested it:

for(job in Hudson.instance.items) {
   job.logRotate()
}


Take a look at the examples on the wiki for more info, and if you come
up with something good, you can add it to the list:
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console

Regards,
Chris
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

jdhein


On Oct 7, 4:11 am, Christopher Orr <[hidden email]> wrote:

> On 06/10/11 21:19, jdhein wrote:
>
> > My organization has just tons of projects in Jenkins, many of which
> > are not active and have not built in some time, some of them haven't
> > built in over 17 months. I have gone through and turned on "discard
> > old builds" with a max of 10 builds. However, it has been weeks since
> > changing this setting and Jenkins has not deleted the excess builds. I
> > am guessing I have to poke the bear by kicking off a build... only, I
> > don't want to do this for projects I am not directly involved with.
>
> > Is there a way to tell Jenkins to go ahead and discard the old builds
> > right now?
>
> You can use the Script Console to fetch the jobs you want, and then call
> logRotate() on each of them.
>
> Probably something like this should work, not that I've tested it:
>
> for(job in Hudson.instance.items) {
>    job.logRotate()
>
> }
>
> Take a look at the examples on the wiki for more info, and if you come
> up with something good, you can add it to the list:https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
>
> Regards,
> Chris

Thanks, the groovy script you gave me worked like a champ with the
only change I made being to add an import:

import hudson.model.*
for(job in Hudson.instance.items) {
   job.logRotate()
}

Honestly, without the groovy script you gave me I would not have been
able to come up with this without investing a bunch of time
researching how Jenkins works and how to write groovy scripts. So
thanks a bunch!
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

David Vree
This worked for me except for one thing.  In a multi-module Maven project the child modules still have all their builds on the filesystem, even though they are gone in the UI.

On Friday, October 7, 2011 6:58:50 PM UTC-4, jdhein wrote:


On Oct 7, 4:11 am, Christopher Orr <[hidden email]> wrote:

> On 06/10/11 21:19, jdhein wrote:
>
> > My organization has just tons of projects in Jenkins, many of which
> > are not active and have not built in some time, some of them haven't
> > built in over 17 months. I have gone through and turned on "discard
> > old builds" with a max of 10 builds. However, it has been weeks since
> > changing this setting and Jenkins has not deleted the excess builds. I
> > am guessing I have to poke the bear by kicking off a build... only, I
> > don't want to do this for projects I am not directly involved with.
>
> > Is there a way to tell Jenkins to go ahead and discard the old builds
> > right now?
>
> You can use the Script Console to fetch the jobs you want, and then call
> logRotate() on each of them.
>
> Probably something like this should work, not that I've tested it:
>
> for(job in Hudson.instance.items) {
>    job.logRotate()
>
> }
>
> Take a look at the examples on the wiki for more info, and if you come
> up with something good, you can add it to the list:https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
>
> Regards,
> Chris

Thanks, the groovy script you gave me worked like a champ with the
only change I made being to add an import:

import hudson.model.*
for(job in Hudson.instance.items) {
   job.logRotate()
}

Honestly, without the groovy script you gave me I would not have been
able to come up with this without investing a bunch of time
researching how Jenkins works and how to write groovy scripts. So
thanks a bunch!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

Richard Bywater-2
Interesting - do they get cleaned up under normal circumstances? (i.e. when a normal discard is done)

Richard.


On Wed, Aug 7, 2013 at 4:24 PM, David Vree <[hidden email]> wrote:
This worked for me except for one thing.  In a multi-module Maven project the child modules still have all their builds on the filesystem, even though they are gone in the UI.

On Friday, October 7, 2011 6:58:50 PM UTC-4, jdhein wrote:


On Oct 7, 4:11 am, Christopher Orr <[hidden email]> wrote:

> On 06/10/11 21:19, jdhein wrote:
>
> > My organization has just tons of projects in Jenkins, many of which
> > are not active and have not built in some time, some of them haven't
> > built in over 17 months. I have gone through and turned on "discard
> > old builds" with a max of 10 builds. However, it has been weeks since
> > changing this setting and Jenkins has not deleted the excess builds. I
> > am guessing I have to poke the bear by kicking off a build... only, I
> > don't want to do this for projects I am not directly involved with.
>
> > Is there a way to tell Jenkins to go ahead and discard the old builds
> > right now?
>
> You can use the Script Console to fetch the jobs you want, and then call
> logRotate() on each of them.
>
> Probably something like this should work, not that I've tested it:
>
> for(job in Hudson.instance.items) {
>    job.logRotate()
>
> }
>
> Take a look at the examples on the wiki for more info, and if you come
> up with something good, you can add it to the list:https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
>
> Regards,
> Chris

Thanks, the groovy script you gave me worked like a champ with the
only change I made being to add an import:

import hudson.model.*
for(job in Hudson.instance.items) {
   job.logRotate()
}

Honestly, without the groovy script you gave me I would not have been
able to come up with this without investing a bunch of time
researching how Jenkins works and how to write groovy scripts. So
thanks a bunch!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

Daniel Beck
In reply to this post by David Vree
What version of Jenkins are you using?

On 07.08.2013, at 06:24, David Vree <[hidden email]> wrote:

> This worked for me except for one thing.  In a multi-module Maven project the child modules still have all their builds on the filesystem, even though they are gone in the UI.
>
> On Friday, October 7, 2011 6:58:50 PM UTC-4, jdhein wrote:
>
>
> On Oct 7, 4:11 am, Christopher Orr <[hidden email]> wrote:
> > On 06/10/11 21:19, jdhein wrote:
> >
> > > My organization has just tons of projects in Jenkins, many of which
> > > are not active and have not built in some time, some of them haven't
> > > built in over 17 months. I have gone through and turned on "discard
> > > old builds" with a max of 10 builds. However, it has been weeks since
> > > changing this setting and Jenkins has not deleted the excess builds. I
> > > am guessing I have to poke the bear by kicking off a build... only, I
> > > don't want to do this for projects I am not directly involved with.
> >
> > > Is there a way to tell Jenkins to go ahead and discard the old builds
> > > right now?
> >
> > You can use the Script Console to fetch the jobs you want, and then call
> > logRotate() on each of them.
> >
> > Probably something like this should work, not that I've tested it:
> >
> > for(job in Hudson.instance.items) {
> >    job.logRotate()
> >
> > }
> >
> > Take a look at the examples on the wiki for more info, and if you come
> > up with something good, you can add it to the list:https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console 
> >
> > Regards,
> > Chris
>
> Thanks, the groovy script you gave me worked like a champ with the
> only change I made being to add an import:
>
> import hudson.model.*
> for(job in Hudson.instance.items) {
>    job.logRotate()
> }
>
> Honestly, without the groovy script you gave me I would not have been
> able to come up with this without investing a bunch of time
> researching how Jenkins works and how to write groovy scripts. So
> thanks a bunch!
>
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

Ashish Palecha
In reply to this post by jdhein
Hey Jdhein,

can u pls provide me whole groovy code what u r using for ur project.
because i am also facing same problem.



On Saturday, October 8, 2011 at 4:28:50 AM UTC+5:30, jdhein wrote:


On Oct 7, 4:11 am, Christopher Orr <[hidden email]> wrote:

> On 06/10/11 21:19, jdhein wrote:
>
> > My organization has just tons of projects in Jenkins, many of which
> > are not active and have not built in some time, some of them haven't
> > built in over 17 months. I have gone through and turned on "discard
> > old builds" with a max of 10 builds. However, it has been weeks since
> > changing this setting and Jenkins has not deleted the excess builds. I
> > am guessing I have to poke the bear by kicking off a build... only, I
> > don't want to do this for projects I am not directly involved with.
>
> > Is there a way to tell Jenkins to go ahead and discard the old builds
> > right now?
>
> You can use the Script Console to fetch the jobs you want, and then call
> logRotate() on each of them.
>
> Probably something like this should work, not that I've tested it:
>
> for(job in Hudson.instance.items) {
>    job.logRotate()
>
> }
>
> Take a look at the examples on the wiki for more info, and if you come
> up with something good, you can add it to the list:<a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins-ci.org%2Fdisplay%2FJENKINS%2FJenkins%2BScript%2BConsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH4m3KVKnHCGdnURO2OVmdIvXW4iw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins-ci.org%2Fdisplay%2FJENKINS%2FJenkins%2BScript%2BConsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH4m3KVKnHCGdnURO2OVmdIvXW4iw&#39;;return true;">https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
>
> Regards,
> Chris

Thanks, the groovy script you gave me worked like a champ with the
only change I made being to add an import:

import hudson.model.*
for(job in Hudson.instance.items) {
   job.logRotate()
}

Honestly, without the groovy script you gave me I would not have been
able to come up with this without investing a bunch of time
researching how Jenkins works and how to write groovy scripts. So
thanks a bunch!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/808240be-de1e-4c0a-a5f5-aebcdf9328c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to make "discard old builds" happen right now?

lakshmi soma
In reply to this post by Christopher Orr
hi can you provide me whole groovy code


On Friday, October 7, 2011 at 4:11:28 AM UTC-6, Christopher Orr wrote:
On 06/10/11 21:19, jdhein wrote:

> My organization has just tons of projects in Jenkins, many of which
> are not active and have not built in some time, some of them haven't
> built in over 17 months. I have gone through and turned on "discard
> old builds" with a max of 10 builds. However, it has been weeks since
> changing this setting and Jenkins has not deleted the excess builds. I
> am guessing I have to poke the bear by kicking off a build... only, I
> don't want to do this for projects I am not directly involved with.
>
> Is there a way to tell Jenkins to go ahead and discard the old builds
> right now?

You can use the Script Console to fetch the jobs you want, and then call

logRotate() on each of them.

Probably something like this should work, not that I've tested it:

for(job in Hudson.instance.items) {
   job.logRotate()
}


Take a look at the examples on the wiki for more info, and if you come
up with something good, you can add it to the list:
<a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins-ci.org%2Fdisplay%2FJENKINS%2FJenkins%2BScript%2BConsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH4m3KVKnHCGdnURO2OVmdIvXW4iw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins-ci.org%2Fdisplay%2FJENKINS%2FJenkins%2BScript%2BConsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH4m3KVKnHCGdnURO2OVmdIvXW4iw&#39;;return true;">https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console

Regards,
Chris

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b9cd4421-ffc1-4fc6-b86c-91ba106b87e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.