Skip to content

Instantly share code, notes, and snippets.

@prerak-proof
Created April 6, 2021 21:57
Show Gist options
  • Save prerak-proof/2f7247ab6cb09edb298a05a20e2da456 to your computer and use it in GitHub Desktop.
Save prerak-proof/2f7247ab6cb09edb298a05a20e2da456 to your computer and use it in GitHub Desktop.
Jenkins set build discarder
processGroup(Jenkins.instance)
def processGroup(itemGroup) {
itemGroup.items.each { j ->
if (j.class.simpleName == "Folder") {
processGroup(j)
} else {
if (j.supportsLogRotator()) {
j.setBuildDiscarder(new hudson.tasks.LogRotator(365, 30, 365, 30))
println(j)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment