Get result of build step

96 views
Skip to first unread message

Marat Gareev

unread,
Sep 14, 2020, 12:50:33 PM9/14/20
to jenkins...@googlegroups.com
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? 

Stuart Rowe

unread,
Sep 14, 2020, 1:43:30 PM9/14/20
to Jenkins Users
The triggerRemoteJob pipeline step returns a Handle, while the build pipeline step returns a RunWrapper when wait is enabled (default behavior).

Marat Gareev

unread,
Sep 15, 2020, 8:07:09 AM9/15/20
to jenkins...@googlegroups.com
Thank you! It became clearer.

пн, 14 сент. 2020 г. в 20:43, Stuart Rowe <stuar...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fc8ecbc7-e06d-4255-9a31-7aa3923da59co%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages