Last active
March 23, 2018 09:19
-
-
Save ansig/b8de81196870c7fc70300327b9b1ce9f to your computer and use it in GitHub Desktop.
Find root cause of a Jenkins build with a trampoline closure
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 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