You can have Jenkins installed on one machine, known as a master, and use it to run projects that control your day-to-day
development processes on other machines, known as agents. This can be very helpful if you need to ensure that your applications
run correctly on a variety of different test configurations.
Note: An agent can either be a physical or a virtual machine.
The process of setting up agents in Jenkins is as follows:
- In Jenkins on the master, create a node that defines a connection to the machine you want to use as an agent. See the example
below for instructions.
- On the agent, open the Jenkins UI. Open the page for the node and follow the link to launch a Jenkins agent which will establish
a connection between Jenkins on the master machine and the agent machine.
- In Jenkins on the master, create a project and configure it to execute on the agent.
Example of Creating Agent Machines
The following example shows how to create a connection to an agent machine which is stored in a vSphere cloud. This requires
that you install the vSphere plugin in Jenkins.
Ensure that Jenkins is connected to the vSphere cloud:
- From the Jenkins Home page, click
Manage Jenkins.
- Click
General.
- Under the
Cloud section, click
Add new cloud > vSphere cloud.
- Specify the configuration and login details for connecting to the vSphere host that contains your virtual machines.
To create a connection to an agent machine, first create a node in Jenkins as follows:
- Click
Manage Jenkins.
- Click
Manage Nodes.
This opens the
Nodes page showing the machine that has Jenkins installed as the master.
- Click
New Node.
- Specify a name for the node and click
Permanent Agent, then click
OK.
- Fill in the details as required - for example, specify a
Remote root directory if this is needed for checking out sources on the agent.
- Click
Save.
To configure the agent to connect to the master:
- On the agent machine, load the Jenkins Home page (http://mastermachine:8080).
- From the Jenkins Home page, click the node for the machine that appears under the Build Execution Status box.
- From the Jenkins page for the node, click
Launch to start the agent that connects the machine to Jenkins.
Configure an existing project to execute on the agent as follows:
- On the master machine, go to the project configuration page.
- Check
Restrict where this project can be run in the
General section.
- In the
Label Expression, specify the name of the node that you just created and connected to.
- Save the project.
Next time you build the project, it will execute on the agent.