abergmeier
abergmeier

Reputation: 14042

Run stages in multiple nodes

I have a declarative pipeline. In this pipeline I want various stages not executed by only one but multiple nodes (later stages, which are node specific, depend on these). Is this somehow possible?

Upvotes: 0

Views: 1209

Answers (2)

ANIL
ANIL

Reputation: 2682

You can follow the following format in your pipeline job to perform specific tasks on specific nodes:

node('master') { 
   ..................... 
   <some task to perform>
   .....................
} 
node('slave1 && slave2') { 
   .....................
   <some task to perform>
   .....................
}

Upvotes: 0

burnettk
burnettk

Reputation: 14047

sure, you can select different nodes in different stages based on label:

pipeline {
  agent none
  stages {
    stage('build') {
      steps {
        node('docker') {
          sh 'echo $HOSTNAME'
        }
      }
    }
    stage('test') {
      steps {
        node('rbenv') {
          sh 'echo $HOSTNAME'
        }
      }
    }
  }
}

does that make sense?

Upvotes: 1

Related Questions