Last active
February 26, 2022 18:47
-
-
Save cmaggiulli/fbb2747a831c5f3b22d55d17e24735c0 to your computer and use it in GitHub Desktop.
Builds Between
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
| /** | |
| * @author Chris Maggiulli | |
| * @description This script will print the job name and build number of all jobs in the last N days. | |
| */ | |
| final jenkins = Jenkins.instance | |
| final lookBack = -1 // Number of days to look back | |
| // Using legacy Calendar instead of Instant due hudson.model.Run.timestamp parameter | |
| final before = Calendar.instance | |
| final after = Calendar.instance | |
| before.add( Calendar.DATE, 0 ) // today | |
| after.add( Calendar.DATE, lookBack ) // today - 1 | |
| before.setTime( before.time ) | |
| after.setTime( after.time ) | |
| println String.format("Jobs executed between %s and %s", before.time, after.time) | |
| jenkins.getAllItems(Job.class).each{ job -> | |
| job.builds.findAll{ run -> run.timestamp?.before( before ) && run.timestamp?.after( after ) }.each { run -> | |
| println String.format( "%s | %o | %s | %s", job.name, run.number, run.description, run.time ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment