Created
April 30, 2018 19:57
-
-
Save slide/b7336e5d671b87be80831a086a8f9da5 to your computer and use it in GitHub Desktop.
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
@NonCPS | |
def getLastJobInfo(build) { | |
def res = null | |
try { | |
if(build.previousBuild != null) { | |
def resp = httpRequest(quiet: true, url: "http://SERVER/jenkins/job/SOMEJOB/job/Pipeline/${build.previousBuild.id}/wfapi/describe") | |
res = readJSON(text: resp.content) | |
} | |
} catch(e) { | |
res = null | |
} | |
return res | |
} | |
... | |
try { | |
lastJob = getLastJobInfo(currentBuild.rawBuild) | |
if(lastJob != null) { | |
def s = lastJob.stages.find { st -> st.name.compareToIgnoreCase(stageName) == 0 && st.status != 'SUCCESS' } | |
if(s != null) { | |
// do something here! | |
} | |
} | |
} catch(e) { | |
// some error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment