kibana/vars/jenkinsApi.groovy
2020-07-21 16:51:58 -04:00

22 lines
728 B
Groovy

def getSteps() {
def url = "${env.BUILD_URL}api/json?tree=actions[nodes[iconColor,running,displayName,id,parents]]"
def responseRaw = httpRequest([ method: "GET", url: url ])
def response = toJSON(responseRaw)
def graphAction = response?.actions?.find { it._class == "org.jenkinsci.plugins.workflow.job.views.FlowGraphAction" }
return graphAction?.nodes
}
def getFailedSteps() {
def steps = getSteps()
def failedSteps = steps?.findAll { (it.iconColor == "red" || it.iconColor == "red_anime") && it._class == "org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode" }
failedSteps.each { step ->
step.logs = "${env.BUILD_URL}execution/node/${step.id}/log".toString()
}
return failedSteps
}
return this