Hello,
I'm trying to use enum for processing the result of the build step.
Working example of using triggerRemoteJob:
def jobBuild = triggerRemoteJob remoteJenkinsName: remoteJenkins, job: jobName,
shouldNotFailBuild: true
if (jobBuild.getBuildResult() != Result.SUCCESS) {
currentBuild.result = Result.UNSTABLE.toString()
}
But the same solution for build doesn't work (always falls to if statement)
import hudson.model.Result
...
Map job = [:]
String jobName = "My-Local-Job"
job["job"] = jobName
job["parameters"] = [
[$class: 'StringParameterValue', name: 'GIT_BRANCH', value: BRANCH]]
job["wait"] = true
def jobBuild = build job
if (jobBuild.getResult() != Result.SUCCESS) {
currentBuild.result = Result.FAILURE.toString()
error "Build was failed"
}
So, I have to work with strings
String jobResult = jobBuild.getResult()
if (jobResult != "SUCCESS") {
currentBuild.result = 'FAILURE'
error "Build was failed"
}
How can I use enum with the build step?