0

I'm attempting to use parallel builders in my scripted jenkinsfile. When I run the code jenkins is ignoring the node labels and just choosing the first available. What am I doing wrong?

here is the code:

  node {
    withCredentials([
        string(credentialsId: 'some ID', variable: 'some variable')
    ]) {
      stage('Initialize') {
        setup()
      }
    }
  }
}


def setup_worker() {
  def labels = ['label2', 'label1']
  def builders = [:]
  for (x in labels) {
    def label = x
    builders[label] = {
      node(label) {
        stage('Setup') {
          step1
          checkout scm
          login()
          write_config()
        }
      }
    }
  }
  parallel builders
}```
daspilker
  • 8,154
  • 1
  • 35
  • 49
Mike W
  • 1

1 Answers1

0

I would highly recommend to use Jenkins Declarative pipelines for handling parallel stages on different nodes. The syntax is simpler and well documented

https://jenkins.io/blog/2017/09/25/declarative-1/

fredericrous
  • 2,833
  • 1
  • 25
  • 26