parallel-stage.groovy

Jenkins pipeline with parallel stage.

6

Votes

node {
  for (int i=0; i< 2; ++i) {  
    stage "Stage #"+i
    print 'Hello, world $i!'
  }

  stage "Stage Parallel"
  def branches = [:]
  for (int i = 0; i < numHelloMessages.toInteger(); i++) {
    branches["split${i}"] = {
      stage "Stage parallel- #"+i
      node('remote') {
       echo  'Starting sleep'
       sleep 10
       echo  'Finished sleep'
      }
    }
  }
  parallel branches
}

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png