Last active
November 19, 2015 13:47
-
-
Save tizki/6088f05ec62fff745cc6 to your computer and use it in GitHub Desktop.
Jenkins groovy script - print enabled old jobs with filter
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
def numOfMonths = 4 | |
Calendar calendar = Calendar.getInstance(); | |
calendar.add( Calendar.MONTH, numOfMonths * -1 ); | |
def threeMonthsAgo = calendar.getTime() | |
def filterClosure = { job -> ((job.getLastBuild()?.timestamp?.time?.before(threeMonthsAgo) && job.getLastBuild() != null) | |
&& job.name.toLowerCase().contains('-Branch-'.toLowerCase()) && job.name.toLowerCase().startsWith('MaaS'.toLowerCase()) | |
&& !job.name.toLowerCase().contains('Infra'.toLowerCase()) && !job.isDisabled() ) } | |
def printClosure = { job -> | |
println("${job.name}") | |
} | |
println ("Builds that run for more than half an hour:") | |
[hudson.model.FreeStyleProject.class, com.tikal.jenkins.plugins.multijob.MultiJobProject.class, hudson.matrix.MatrixProject.class] | |
.each { className -> | |
def foundJobs = jenkins.model.Jenkins.instance.getAllItems(className).findAll(filterClosure).each(printClosure)}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment