Shweta Bagul
4 min readJun 25, 2020

--

HOW TO SET UP JENKINS MASTER AND AGENT MACHINES ON WINDOWS

Purpose of this article:

How to configure the Jenkins agent on windows environment using java web start instead of ssh

Overview:

Jenkins undoubtedly is the leading open source automation server, widely used in DevOps culture. Being self contained Java based program, it is easy to install as well to configure.

How Jenkins manages distributed hosts:

A simple & sweet monolithic Jenkins installation can work great for small number of projects but it becomes important to scale it up as the number of projects grow. To handle this, Jenkins has Master/Agent implementation strategy(previously known as Master/Slave). Jenkins Master is the central, coordinating process which stores configuration, loads plugins, and renders the various user interfaces for Jenkins. Jenkins agent is typically a machine, or container, which connects to a Jenkins master and executes tasks when directed by the master. The connection can basically be established by either of the below ways-

a. Trigger agent with SSH from Master

b. Trigger agent using Java web start

Generally while working in Linux environments, most of us prefer to connect using ssh connection with agents as it is quick and time saving. But for windows environment, we have to take help of java web start framework.

Prerequisites:

  1. Jenkins master configured and running.
  2. Java Runtime environment should be installed on agent machine.

Configuration:

Jenkins Master
Goto Jenkins -> Manage Jenkins -> Manage nodes

In the Manage nodes page, Select New node

Give node name. choose permanent agent.

Click Ok.

At the agent node, an agent needs to have a directory dedicated to Jenkins. Specify the path to this directory on the agent.

In our case it’s C:\Jenkins.

The Launch method Controls how Jenkins starts this agent. We have installed JRE at the agent node. so choose Launch agent via Java Web Start

In this case, a JNLP file must be opened on the agent machine, which will establish a TCP connection to the Jenkins master. This means that the agent need not be reachable from the master; the agent just needs to be able to reach the master.

If you have enabled security via the Configure Global Security page, you can customize the port on which the Jenkins master will listen for incoming JNLP agent connections.

By default, the JNLP agent will launch a GUI, but it’s also possible to run a JNLP agent without a GUI, e.g. as a Window service.

For our Jenkins master, goto Jenkins -> Manage Jenkins -> Configure Global security

and give the port as 49187. Also make sure Jenkins URL(Under Location) is UpToDate.

On the agent machine, Open web browser and give master Jenkins URL i.e. 192.168.100.65:9000/

Go to Manage Jenkins > Manage Nodes, Click on the newly created agent machine.

Click on Launch agent. You should see a window like this-

Choose “File” > “Install as Windows Service” from the menu-

Confirm your intention to install as a service. click ok. You will be able to see the new service as below-

Hurray! the config is done!

Now if you want to run specific job on Jenkins agent node, while specifying job configuration, Tick the checkbox Restrict where this project can be run

Running a Job from Master:

While configuring a job, in the Label expression provide the exact name of the agent node (listed in manage nodes section)

And done! In this way, you are good to execute any kind of jobs on multiple windows agents machine remotely. You can handle tens of thousands agents without any hassle!

--

--