Skip to main content

How do I set discard old builds for a Multi Branch Pipeline Job?

Comments

4 comments

  • Timothy Reaves

    Using this suggestion leads to invalid code.

    0
  • David Sanftenberg

    This needs to be configurable at the root level. Adding it into every Jenkinsfile in a Github organization is not feasible when we have hundreds of repos. 

    4
  • Philip Wofford

    David, love the pic, I've joked about using that image as a "wall paper" of sorts for my entire 'hexicle' (not quite a cube!). I agree, it would make sense for this to be configurable as a default in Jenkins and then allow a Jenkinsfile to override the instance settings. This is a fairly common convention in many places, a hierarchy of command/authority. 

    1
  • Brandon Bhagwandeen

    import hudson.model.*

     

    Hudson.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob).each { job ->

       if(job.getBuildDiscarder() == null) {

       job.logRotator = new hudson.tasks.LogRotator(int,int) // (int,int,int,int) to include artifacts

       }

    }

     

    You should have the Pipeline plugin installed.

    0

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.