Created
April 28, 2020 14:53
-
-
Save marcosborges/e7e129a4a97e3e299e645312b7ef9262 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.Jenkins | |
import hudson.model.Job | |
import jenkins.model.BuildDiscarderProperty | |
import hudson.tasks.LogRotator | |
def total = 0 | |
// LogRotator ( daysToKeep, numToKeep, artifactDaysToKeep, artifactNumToKeep) | |
// daysToKeep: If not -1, history is only kept up to this days. | |
// numToKeep: If not -1, only this number of build logs are kept. | |
// artifactDaysToKeep: If not -1 nor null, artifacts are only kept up to this days. | |
// artifactNumToKeep: If not -1 nor null, only this number of builds have their artifacts kept. | |
Jenkins.getInstance().getAllItems().each { | |
if( | |
it?.getDescriptor().getDisplayName() == "Pipeline" && | |
it.isBuildable() && | |
it.supportsLogRotator() && | |
it.getProperty(BuildDiscarderProperty) == null | |
) { | |
println "Configure: ${it.getFullName()}" | |
it.addProperty(new BuildDiscarderProperty(new LogRotator ( -1, 10, -1, 10))) | |
total++ | |
} | |
} | |
total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment