<p>Use the <code>result</code> property of object returned from the <code>build</code> step.</p>

<p>This was already asked and <a href="https://stackoverflow.com/a/52961436/1824868">has an answer over on StackOverflow</a>.  Additionally, this is hinted at in the <a href="https://www.jenkins.io/doc/pipeline/steps/pipeline-build-step/" rel="nofollow noreferrer">official build step documentation</a> in the description for the <code>propagate</code> parameter ("use the <code>result</code> property of the return value as needed").  I haven't tested it as I don't have a test Jenkins instance available right now, but based on those two pieces of information it looks like something like this should do the trick:</p>

<pre><code>def b = build('my-job-name', wait: true)

def r = b.result
</code></pre>

CC BY-SA 4.0
2020-05-19T00:25:53.187Z
2020-05-19T00:25:53.187Z
jayhendren
<p>I have a pipeline script that executes child jobs in parallel.</p>

<p>Say I have 5 data (a,b,c,d,e) that has to be executed on 3 jobs (J1, J2, J3)</p>

<p>My pipeline script is in the below format</p>

<p>for (int i = 0; i &lt; size; i++) {
  def index = i 
  branches["branch${i}"] = {
    build job: 'SampleJob', parameters: [
      string(name: 'param1', value:'${data}'),
      string(name:'dummy', value: "${index}")]
  }
}
parallel branches</p>

<p>My problem is, say the execution is happening on Job 1 with the data 1,2,3,4,5 and if the data 3 execution is failed on Job 1 then the data 3 execution should be stopped there itself and should not happen on the subsequent parallel execution on Jobs 2 and 3. </p>

<p>Is there any way that I can read the execution status of parallelly execution job status on the Pipeline script so that I can restrict data 3 execution to block in Jobs 2 and 3.</p>

<p>I am quite blocked here for a long time. Hoping for a solution from my community. Thanks a lot in advance.</p>

<jenkins><jenkins-pipeline><jenkins-plugins>
How can I retrieve the execution status of parallel triggered child jobs to a pipeline script
santhosh shetty
# How can I retrieve the execution status of parallel triggered child jobs to a pipeline script

(Asked by: username_0 on 2020-05-15)

I have a pipeline script that executes child jobs in parallel.

Say I have 5 data (a,b,c,d,e) that has to be executed on 3 jobs (J1, J2, J3)

My pipeline script is in the below format

for (int i = 0; i < size; i++) {
def index = i
branches["branch${i}"] = {
build job: 'SampleJob', parameters: [
string(name: 'param1', value:'${data}'),
string(name:'dummy', value: "${index}")]
}
}
parallel branches

My problem is, say the execution is happening on Job 1 with the data 1,2,3,4,5 and if the data 3 execution is failed on Job 1 then the data 3 execution should be stopped there itself and should not happen on the subsequent parallel execution on Jobs 2 and 3.

Is there any way that I can read the execution status of parallelly execution job status on the Pipeline script so that I can restrict data 3 execution to block in Jobs 2 and 3.

I am quite blocked here for a long time. Hoping for a solution from my community. Thanks a lot in advance.

**Tags:** jenkins, jenkins-pipeline, jenkins-plugins


---

## 1 answers

### Answer by username_1 on 2020-05-19. Score: 2

Use the result property of object returned from the build step.
This was already asked and has an answer over on StackOverflow.  Additionally, this is hinted at in the official build step documentation in the description for the propagate parameter ("use the result property of the return value as needed").  I haven't tested it as I don't have a test Jenkins instance available right now, but based on those two pieces of information it looks like something like this should do the trick:
def b = build('my-job-name', wait: true)

def r = b.result


---

