Skip to content

Instantly share code, notes, and snippets.

@ansig
Last active March 23, 2018 09:19
Show Gist options
  • Save ansig/b8de81196870c7fc70300327b9b1ce9f to your computer and use it in GitHub Desktop.
Save ansig/b8de81196870c7fc70300327b9b1ce9f to your computer and use it in GitHub Desktop.
Find root cause of a Jenkins build with a trampoline closure
def findRootCauseRun
findRootCauseRun = { def currentRun ->
def upstreamRun = getUpstreamCause(currentRun)?.getUpstreamRun()
if (upstreamRun == null) return currentRun
findRootCauseRun.trampoline(upstreamRun)
}
findRootCauseRun = findRootCauseRun.trampoline()
def getUpstreamCause(def run) {
run.getAction(hudson.model.CauseAction.class)?.findCause(hudson.model.Cause$UpstreamCause.class)
}
rootCause = findRootCauseRun(build)
println rootCause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment