Issue
You want to connect multiple Windows agents, each installed as a service.
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed Master
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
-
CloudBees CI (CloudBees Core) on traditional platforms - Client Master
-
CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
-
Microsoft Windows
Resolution
Java Web Start offers the possibility to connect multiple agents on the same machine. In addition, it is possible to install a JNLP agent as a service in Windows. Thus, this article is aimed to explain how to install multiple Windows agents as services.
Install Several Agents
1) Create an agent to launch via Java Web Start
2) There are different ways to launch the agent agent:
- The easiest way is to access Jenkins from the agent machine, go to the node page
computer/<my-node>/
and click on theLaunch
button. This downloads the fileslave-agent.jnlp
and runs it.- Another way is to run the command
java -jar agent.jar -jnlpUrl http://<my-server>/computer/<my-node>/slave-agent.jnlp -secret <my-secret>
described atcomputer/<my-node>/
- You can download
slave-agent.jnlp
from the client master, copy it to the agent machine and runjavaws slave-agent.jnlp
- Another way is to run the command
3) Once the agent is launched, you should see a popup in Windows. To install this agent as a service, click on File/Install as a service
.
4) The service appears in the services popup. (run services.msc
to see windows services). You can double click on the service to show its name:
5) All agents are installed with the same service display name in Windows: “Jenkins Agent”. In order to be able to install several agents, the displayname
needs to be modified. Run the following command as an administrator to change the display name of the service.
> $ sc config <service-name> displayname="jenkins-agent-1"
6) In order to delete an already existing agent
> $ sc delete <service-name>
7) For each agent you want to add and install as a service, reproduce steps 1 to 6.
Configure Agent User
Although it is recommended to run master/agents with a single jenkins user, it is possible to run each agent as a different user. This can be configured in the agent service properties, in the logon tab. For example, the following agent is run with the user Administrator
:
Further Information
Further documentation can be found on the wiki regarding Windows agent.
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service
https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
https://wiki.jenkins-ci.org/display/JENKINS/Launch+Java+Web+Start+slave+agent+via+Windows+Scheduler
3 Comments