'How to run a 2 Jenkins slaves simultaneously with only one trigger from the job of master

I have a selenium automation project with Maven and I am currently using XML files to run the batches of test cases locally.

Now I have a requirement to run the whole suite in Jenkins, and for that, I have 2 slave EC2 instances with the project. I configured two XML files for those two slaves to divide the suite among them. Now I can build them separately.

I am looking for a solution to trigger both my slaves at the same time when the job on the main is being built so that I can parallelly execute them with my Jenkins pipeline.



Solution 1:[1]

Label both your instances, lets say label1 and label2

then..

stage('Tests') {
        parallel {
            stage('Suite1') {
                steps {
                    node('label1') {
                       //do something...
                    } 
                }
            }
            stage('Suite2') {
                steps {
                    node('label2') {
                       //do something...
                    }
                }
            }
        }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaus2b