how to get parallel build job result in jenkins

My Jenkins job run multiple builds in parallel as below:

def branches = [:]


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

For the above code I want to print all build result. So how can I get build result (e.g. SUCCESS, FAILURE...) of all parallel jobs?

1 answer

  • answered 2020-10-01 08:10 vipin yadav

    If you want to print all branches result in the same console you can do it like this

    def branches = [:]
    for (int i = 0; i < 4; i++) {
     def index = i 
      branches["branch${i}"] = {
      build job: 'Test', parameters: [
      string(name: 'param1', value:'test_param'),
      string(name:'dummy', value: "${index}")]
     }
      println currentBuild.result
    }
    parallel branches
    

    currentBuild.result holds status of the build so if you print it in each branch you will get what you need. If the stage