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

+2 votes

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 slave1the 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.

Jul 9, 2018 in Jenkins by shubham
• 7,340 points
49,018 views

4 answers to this question.

+1 vote

Below is an approach which you can try.

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.

answered Jul 9, 2018 by Atul
• 10,240 points
I'm using Multi configuration CI..

I have configured 3 slaves and selected shell and written some commands..

When i configure poll scm, It will start and execute all nodes at same time..

But, I need to start each slave with different different timings. is it possible ?
+1 vote
use multijob plugin
answered Jan 3, 2019 by Ajit Jadhav
hey @Ajit, Can you please elaborate and explain?

Follow these steps to use the multijob plugin: 

  • When creating new Jenkins jobs you will have an option to create MultiJob project.
  •  In the build section, this job can define phases that contain one or more jobs.
  •  All jobs that belong to one phase will be executed in parallel (if there are enough executors on the node)
  •  All jobs in phase 2 will be executed only after the jobs in phase 1 are completed etc.
Hey thanks @Vishal, Make this an answer for better readability and understanding.
Hey @kalgi, I've written an answer, please do upvote if you think makes sense and is understandable.
Hello

I am new to jenkins.

and am seeing this option

may be to organize and increase performance

does anyone have an example.

I wouldn't mind giving it a try

got workers that are locking up

needing to reboot clusters often