Skip to content

Instantly share code, notes, and snippets.

@or-shachar
Created December 7, 2017 16:46
Show Gist options
  • Save or-shachar/572338c62be71d3651f16fc632337d2e to your computer and use it in GitHub Desktop.
Save or-shachar/572338c62be71d3651f16fc632337d2e to your computer and use it in GitHub Desktop.
Counts jobs that failed by name
job_name="some-name" //I have multiple jobs with the same simple name under multiple folders
instance = Jenkins.instance
def jobs = instance.allItems.findAll{it.name==job_name}
count = 0
for (job in jobs){
lastRun = job.lastCompletedBuild
if (lastRun==null || lastRun.result != Result.SUCCESS){
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