>
> On Wednesday, March 1, 2017 at 4:08:53 AM UTC-5, Baptiste Mathus wrote:
>>
>> I don't think there's something per branch, but you probably want to 
>> either search JIRA and/or file a new feature request about it.
>>
>> You shouldn't need a special plugin, this is a standard feature. Here's 
>> the way to do it with Declarative Pipeline: 
>>
>> pipeline {
>>     options {
>>         buildDiscarder(logRotator(numToKeepStr: '20'))
>>     }
>> ...
>> }
>>
>> Or with scripted Pipeline: 
>> https://github.com/jenkinsci/jenkins/blob/master/Jenkinsfile#L17-L19
>>
>

I'm stil not seeing any signs that the buildDiscarder plugin is working for 
me. At the top of my Jenkinsfile, I have this:

properties([[ 
 $class: 'jenkins.model.BuildDiscarderProperty', 
  strategy: [$class: 'LogRotator', numToKeepStr: '50', 
artifactNumToKeepStr: '50'] 
]]) 

That's just above my  "node {}" block. 

>From reading related source code at:
https://github.com/jenkinsci/jenkins/blob/08def67a18eee51de9f3f99bc2a792fee1c160e0/core/src/main/java/hudson/tasks/LogRotator.java

I can see that this function should generate some logging, but I can't find 
the log entries indicating this is running in either the web-based Jenkins 
log page, or under /var/log/jenkins/*

The effective-but-imperfect workaround I've found is to just manually 
delete only builds:

    find "/var/lib/jenkins/jobs/My Pipeline/branches/" -mindepth 3 
-maxdepth 3 -type d -ctime +15 | xargs -d '\n' rm -rf

That doesn't have the safety nets of preserving any builds that are 
last-successful, promoted, etc. 

Some questions:

  * Should the logging I see in the source code *always* be happening or 
there something I need to do activate that logging?
  * Should properties() call work outside a node block?
  * Are there any serious drawbacks to just manually deleting old build 
myself? This built-in log rotation has proven especially time-consuming for 
what seems like it should be a simple feature to setup. 

Thanks,

      Mark

2017-02-28 20:24 GMT+01:00 Mark Stosberg <ma...@rideamigos.com>:
>>
>>> For cleaning up old builds, the "Discard Old Builds" plugin is 
>>> recommended:
>>>
>>> https://wiki.jenkins-ci.org/display/JENKINS/Discard+Old+Build+plugin
>>>
>>> However, the instructions for reference a "post build" step which 
>>> doesn't exist in the Configure interface for Multibranch Pipeline projects. 
>>>
>>> What's the recommended way to clean-up builds from multi-branch pipeline 
>>> projects? Ideally I'd like different pruning policies for different 
>>> branches. 
>>>
>>> Thanks,
>>>
>>>      Mark
>>>
>>> -- 
>>> 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 jenkinsci-use...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/1d9e0343-bbce-474f-a4fe-7623a4f39aaf%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jenkinsci-users/1d9e0343-bbce-474f-a4fe-7623a4f39aaf%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/67e52c4d-8131-4ef7-8446-8cee1f31dce3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to