I have a Jenkins pipeline job called \"TestPipeline\". I want to trigger a build on 2 different slaves which labeled \"tester1\' and \"tester2\". And the pipeline script is
Here is how i got it working
create a 'job' 'test_job' with parameter type 'label' , name 'node', value can be any string. (this is the job to be triggered) .Set 'Restrict where this project can be run' to the label value
create a 'pipeline' with parameter type "Node". From the pipeline section, use the following script
Note the label for test_job is ${env.NODE_NAME} which will be set by the pipeline based on user's choice
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
script {
build job: 'test_job', parameters: [
[$class: 'LabelParameterValue', name: 'node', label: "${env.NODE_NAME}" ]
]
}}}}}