Get result of build step

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Get result of build step

Marat Gareev
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? 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAGBFc1WPfwoRz7873PehzmxC7NF0B9ue%3D%3Dh9oh3YeF2Uz6WntQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get result of build step

stuartrowe
The triggerRemoteJob pipeline step returns a Handle, while the build pipeline step returns a RunWrapper when wait is enabled (default behavior).

On Monday, 14 September 2020 09:50:33 UTC-7, Marat Gareev wrote:
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? 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fc8ecbc7-e06d-4255-9a31-7aa3923da59co%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get result of build step

Marat Gareev
Thank you! It became clearer.

пн, 14 сент. 2020 г. в 20:43, Stuart Rowe <[hidden email]>:
The triggerRemoteJob pipeline step returns a Handle, while the build pipeline step returns a RunWrapper when wait is enabled (default behavior).

On Monday, 14 September 2020 09:50:33 UTC-7, Marat Gareev wrote:
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? 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fc8ecbc7-e06d-4255-9a31-7aa3923da59co%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAGBFc1Uoog%3D6fnjE5iLLGE-65aGRnR8qHy12PQLFzmW8KavD%3DQ%40mail.gmail.com.