-
-
Save electron0zero/6669abef9f3ec4c9bb686f0299aacbd4 to your computer and use it in GitHub Desktop.
Quick Jenkins system groovy script to compute how many minutes of build you had in the last N hours
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 numberOfHoursBack = 7*24 | |
| def totalBuildTime = | |
| Jenkins.instance.getItems(Job.class).collect { job -> | |
| job.getBuilds().byTimestamp(System.currentTimeMillis()-numberOfHoursBack*60*60*1000, System.currentTimeMillis()) | |
| } | |
| .flatten() | |
| .collect { build -> build.getDuration() } | |
| .sum() | |
| def totalBuildTimeInMinutes = (int)totalBuildTime/(60*1000) | |
| println "During the last $numberOfHoursBack hours" | |
| println "\t $totalBuildTimeInMinutes minutes total" | |
| println "\t ${totalBuildTimeInMinutes/numberOfHoursBack} minutes per hour in average" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment