Prerequisites
Before proceeding, ensure you have:
✅ A running Jenkins master instance
✅ Java installed on the agent machine
✅ Administrator access on the Windows machine
✅ Winsw.exe package Download Link
Step 1: Download the Jenkins Agent JAR
- From your Jenkins dashboard:
- Navigate to Manage Jenkins > Nodes.
- Click New Node, select Permanent Agent, and configure it (set the remote root directory, labels, etc.).
- Under Launch method, choose Launch agent via Java Web Start.
- Save the node configuration.
- Get the agent JAR URL:
- Click on the newly created node to open its status page.
- Copy the agent JAR URL (e.g.,
http://your-jenkins-server:8080/jnlpJars/agent.jar
).
- Prepare the agent machine:
- Create a directory named JenkinsAgent on your Windows agent machine.
- Open Command Prompt in the newly created directory.
- Download the agent JAR:
curl http://your-jenkins-server:8080/jnlpJars/agent.jar -o agent.jar
Step 2: Creating the Requirement Files
- Download WinSW:
- Download the
winsw.exe
package from the official repository - Save the file to your
JenkinsAgent
directory
- Download the
- Rename the executable:
- Rename
winsw.exe
toJenkinsAgent.exe
in the directory
- Rename
- Create the configuration file:
- In the same directory, create a new file named
JenkinsAgent.xml
- In the same directory, create a new file named
- Verify your files:
- After completing these steps, your directory should contain these three files:

Step 3: Configure the service
- Edit the
JenkinsAgent.xml
file and populate the following fields:<id>
<name>
<executable>
<arguments>
<service>
<id> Service ID e.g (jenkinsagent) </id>
<name> Agent Name e.g (JenkinsAgent) </name>
<description>This service runs the Jenkins Agent as a Windows service.</description>
<executable> Java Path </executable>
<arguments>-Xrs -Xmx256m -jar "%BASE%\agent.jar" -url http://your-jenkins-server:8080/ -secret YOUR_AGENT_SECRET -name windows -webSocket -workDir "D:\Jenkins"</arguments>
<log mode="roll" />
<onfailure action="restart" />
</service>
2. After updating the values, your file should resemble this example:
<service>
<id>jenkinsagent</id>
<name>JenkinsAgent</name>
<description>This service runs the Jenkins Agent as a Windows service.</description>
<executable>C:\Program Files\Common Files\Oracle\Java\javapath\java.exe</executable>
<arguments>-Xrs -Xmx256m -jar "%BASE%\agent.jar" -url http://10.100.28.55:8080/ -secret 52b81a02183007dbaaafbc8decaabe9ba34906828132c432 -name windows -webSocket -workDir "D:\Jenkins"</arguments>
<log mode="roll" />
<onfailure action="restart" />
</service>
3. Save the file after making changes.
Step 4: Install the service
- To install the service, Open Command Prompt as Administrator.
- Navigate to the JenkinsAgent directory by running:
cd C:\JenkinsAgent
- Install the service by executing:
JenkinsAgent.exe install
Step 5: Start the service
- Open the Service Manager on the agent machine:
- Press
Win + R
, typeservices.msc
, and hit Enter. - Locate the service name you specified in the
<id>
field of your configuration file.
- Press
- Configure the Service Account:
- Right-click the service and select Properties.
- Navigate to the Log On tab.
- Enter the credentials for the service account under which the agent should run.
- Click Apply, then OK.
- Start the Service:
- Right-click the service again and select Start.
- Verify the Service Status:
- Option 1: Check the agent’s connection status in the Jenkins UI under Manage Jenkins > Nodes.
- Option 2: Inspect the logs in the
JenkinsAgent
directory: