I have this example pipeline
pipeline {
parameters {
string(name: 'PLATFORM', description: 'target platform to build to')
}
agent {
node {
/* I want to choose 'windows-machine'
when PLATFORM matches "windows.*" */
label 'linux-machine'
}
}
}
I want jobs that target windows platforms to run on different nodes. How can you choose node labels based on whether pipeline parameters match an expression or not?
CodePudding user response:
Instead of node, you can use agent selector label
. Here is an example of how you can do this.
pipeline {
parameters {
string(name: 'PLATFORM', description: 'target platform to build to')
}
agent {label PLATFORM=='WINDOWS' ? 'windows': 'linux'}
stages {
stage('Test') {
steps {
script {
echo "test"
}
}
}
}
}