简体   繁体   中英

How to run Jenkins jobs on multiple slaves with a single job configuration?

I have three different environments each containing a Jenkins Slave,

STAGE1 - slave1
STAGE2 - slave2
STAGE3 - slave3

I don't want to create three different build jobs for them.

I want to pass the slaves ( slave1 , slave2 and slave3 ) as parameters, so that if I choose slave1 the job gets executed on STAGE1 , and if I choose slave2 the job gets executed on STAGE2 and so on.

How to achieve that using a single Jenkins job?

I know there is multi configuration job but I am not clear on how to configure it.

It would be really helpful if I get some information on it.

I figured it out. It can be achieved using,

Node and Label Parameter Plugin

It lets you create node and label parameter in the job configuration.

Node parameter contains all the nodes present in your Jenkins including master, you can select the nodes you want.

When you run the job with parameters you can select the desired node and the job will get executed in that particular node.

I am working in test automation where I need to maintain different environment and deploy jobs to Jenkins, I'm not sure it would be helpful, if it is I will share code snippet(If required).

I am not doing exact thing for environment but I've achieved this thing fro browsers, I am using maven as my build tool so I've made configuration in my code that it will fetch the same browser I'm passing in the command which is set as a goal for single Jenkins job.

Goal example: mvn clean verify -Dtest=test.xml -Dbrowser=chrome

Same can be done for multiple environments as well, you can set a default slave in POM file and make changes configurations changes or you can create 3 multiple files like XML which will contain your executable files and add them as parameter in Jenkins single job.

Hi I was able to achieve to trigger same job in the multiple servers(nodes/slaves) simultaneously with the help of below configuration.

First you have to create the project as below shown below in the screeshot

enter image description here

Then configure the details as below

enter image description here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM