How to Install Several Windows Slaves as a Service?

Issue

You want to connect multiple Windows slaves, each installed as a service.

Environment

  • CloudBees Jenkins Enterprise
  • Windows

Resolution

Java Web Start offers the possibility to connect multiple slaves on the same machine. In addition, it is possible to install a JNLP slave as a service in Windows. Thus, this article is aimed to explain how to install multiple Windows slaves as services.

Install Several Slaves

1) Create a slave to launch via Java Web Start

node-config

2) There are different ways to launch the slave agent:

  • The easiest way is to access Jenkins from the slave machine, go to the node page computer/<my-node>/ and click on the Launch button. This downloads the file slave-agent.jnlp and runs it.
  • Another way is to run the command java -jar slave.jar -jnlpUrl http://<my-server>/computer/<my-node>/slave-agent.jnlp -secret <my-secret> described at computer/<my-node>/
  • You can download slave-agent.jnlp from the client master, copy it to the slave machine and run javaws slave-agent.jnlp

node-launcher

3) Once the slave is launched, you should see a popup in Windows. To install this slave as a service, click on File/Install as a service.

install-service

5) The service appears in the services popup. (run servcies.msc to see windows services). You can double click on the service to show its name:

service-properties

6) All slaves are installed with the same service display name in Windows: “Jenkins Slave”. In order to be able to install several slaves, the displayname needs to be modified. Run the following command as an administrator to change the display name of the service.

$ sc config displayname=“jenkins-slave-1”

7) For each slave you want to add and install as a service, reproduce steps 1 to 6.

several-slaves

Configure Slave User

Although it is recommended to run master/slaves with a single jenkins user, it is possible to run each slave as a different user. This can be configured in the slave service properties, in the logon tab. For example, the following slave is run with the user Administrator:

service-logon

Further Information

Further documentation can be found on the wiki regarding Windows slave.

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

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.