Skip to content
Advertisement

Running Jenkins Node/Agent as a Windows Service with OpenJDK

I have a Windows virtual machine with OpenJDK 13 installed that I would like to setup as a Jenkins node/agent.

When I create the node configuration using the Jenkins UI and select Launch Method: Launch Agent by connecting it to the master it provides a link to download slave-agent.jnlp

On a system with the original jdk/jre older than version 9, which contains java web start, if I run that jnlp file, it brings up a window with a menu that includes an option File – Install as A Service

However, as OpenJDK (and I believe any JRE/JDK versions greater than 8) do NOT contain Java Web Start, I cannot seem to gain access to that option.

I am able to successfully run java -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir “somedirectory” and have the node register with Jenkins, but it is not running as a service.

I had an older agent that was still using old version of JRE, so I looked at its Jenkins service configuration and unfortunately it seems to be relying on executable(s), .config file(s), and xml file(s), which I cannot determine the source of, beyond they must be created when running the “Install as a service” instructions from slave-agent.jnlp

I also attempted to use IcedTea-Web which is apparently supposed to be a Java Web Start replacement, but I’ve had no success.

Can anyone tell me how to setup a Windows machine running OpenJDK as a Jenkins node/agent with the Jenkins node/agent components running as a Windows service?

Advertisement

Answer

I had a similar issue and now I use NSSM.

  1. Download NSSM
  2. Open a cmd and install the service (I used JenkinsService as Servicename):
    <path to nssm.exe>nssm install <Servicename>
    
  3. Insert the path to the jdk to the field Path
  4. add the rest to the field Arguments:
    -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory"
    
  5. Click on install the service

Now you can check the new service JenkinsService in the windows service manager. As soon as it’s running you can check the connection to the master.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement