Created
December 7, 2017 13:18
-
-
Save or-shachar/5b227344e0f5cc2472ff025b9dfb5f5f to your computer and use it in GitHub Desktop.
Count all jobs of certain name that has certain string in their last run
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
job_name="some-job" //I have multiple jobs with the same simple name under multiple folders | |
lookup_string="something inside the log" // the line we want to look for | |
instance = Jenkins.instance | |
def jobs = instance.allItems.findAll{it.name==job_name} | |
count = 0 | |
for (job in jobs){ | |
lastRun = job.lastCompletedBuild | |
lastBuildLog = lastRun.log | |
if (lastBuildLog.contains(lookup_string)){ | |
println job.fullName + " " + instance.rootUrl + lastRun.url | |
count = count + 1 | |
} | |
} | |
println "${count} out of ${jobs.size}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment