Created
March 20, 2020 18:33
-
-
Save abihf/92e9fe6d66fe360c6d0d1671fa477997 to your computer and use it in GitHub Desktop.
This file contains 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 | |
Jenkins.instanceOrNull.allItems(hudson.model.Job).each { job -> | |
if (job.isBuildable() && job.supportsLogRotator() && job.getProperty(jenkins.model.BuildDiscarderProperty) == null) { | |
println "Processing \"${job.fullDisplayName}\"" | |
try { | |
job.setBuildDiscarder(new hudson.tasks.LogRotator ( 14, -1, 14, -1)) | |
println "${job.fullName} is updated" | |
} catch (Exception e) { | |
// Some implementation like for example the hudson.matrix.MatrixConfiguration supports a LogRotator but not setting it | |
println "[WARNING] Failed to update ${job.fullName} of type ${job.class} : ${e}" | |
} | |
} | |
} | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment