cremersstijn
cremersstijn

Reputation: 2395

How to trigger a jenkins build in background while propagating error with the pipeline plugin

I am experimenting with the jenkins pipeline scripting.

I have a job which will call other build for deploying stuff. This is my pipeline script

node {
   stage 'retrieve deploy conf'
   echo 'contacting deploy conf service'
   def dbs = ['db1', 'db2', 'db3']
   for (db in dbs){
    stage 'deploy db ' + db
    echo 'deploy db ' + db
    build job: 'deploy db pipeline', wait: false, parameters: [[$class: 'StringParameterValue', name: 'db', value: db]]

   }
   def jbossApps = ['example-ear1', 'example-ear2']
   for (app in jbossApps){
    stage 'deploy jboss app ' + app
    echo 'deploy jboss app' + app
    build job: 'deploy app pipeline', wait: false
   }
}

For each value in a loop, i want to have different stages (for visibility). I have now set the wait param on the build call to false, but this results that no error are propagated.

Are there any solutions for this?

Upvotes: 1

Views: 1517

Answers (1)

amuniz
amuniz

Reputation: 3342

Use the parallel step (calling one build per branch) and remove wait: false, instead of the for loop.

Use failFast: true in parallel step to stop the build as soon as the first branch fails.

Upvotes: 1

Related Questions