Skip to content

Instantly share code, notes, and snippets.

@kevin-brotcke
kevin-brotcke / DeleteMultiBranchBuilds.groovy
Last active November 9, 2023 17:53
Combined branch build discarder for Jenkins multibranch pipelines
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
/**
* Maintains a build history limit across ALL branches in a pipeline, not just per branch.
*
* <p>This script could be tweaked to save last successful, discard artificats, exclude certain
* branches, include only a certain pipeline, etc. See <a
* href="https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/tasks/LogRotator.java">LogRotator.java</a>
* for more examples.
*