Created
May 8, 2019 18:45
-
-
Save caferrari/b894ded5d051f2fc8381d44266049e34 to your computer and use it in GitHub Desktop.
Jenkins Build Time
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 = 30*24 | |
def diff = ((System.currentTimeMillis() / 1000) - (numberOfHoursBack * 60 * 60)) * 1000 | |
def totalBuildTime = | |
Jenkins.instance.getItems(Job.class).collect { job -> | |
job.getBuilds().byTimestamp(diff.longValue() , 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