Skip to content

Instantly share code, notes, and snippets.

@ansig
Created March 13, 2018 06:51
Show Gist options
  • Save ansig/7b49cab240bfaa06c83577852c734196 to your computer and use it in GitHub Desktop.
Save ansig/7b49cab240bfaa06c83577852c734196 to your computer and use it in GitHub Desktop.
List failing branches of failing builds in a Jenkins Pipeline
jobs = Jenkins.instance.allItems(hudson.model.Job).findAll { it.fullName == ("<JOBNAME>") }
jobs.each { job ->
job.builds.findAll { !it.building }.each { build ->
finished = new Date(build.timestamp.timeInMillis + build.duration)
println "${build} - ${build.result} (${finished})"
action = build.getAction(org.jenkinsci.plugins.workflow.job.views.FlowGraphAction)
action.getNodes().findAll { it.displayName.startsWith("") }.each {
if (it.displayName.startsWith("Building") && it.getError() != null) {
println "\t${it.displayName}"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment