Jenkins Windows Slave Configuration with Screenshots

Topic General, Tools

In our last articles, we have discussed how to Install and Configure Jenkins and how to Configure Jenkins Master-Slave setup on Linux machine

I have received few requests/suggestions through my last article  Jenkins Master-Slave setup on Linux machine to share the approach on Configuring Jenkins Slave on Windows Machine

So here I am with our new article on How to Configure a Jenkins Slave on Windows Machine and Install it as a windows Service

jenkins-windows

1- Login to Jenkins and Click on Manage Jenkins

jenkins-windows-slave-creation-1

2- To create a new Slave – Click on New Node

jenkins-windows-slave-creation-2

 

3- Name the node

jenkins-windows-slave-creation-3

 

4- Fill all the required details.

Please refer our master-slave configuration article to know all the details of parameters present in the node configuration page

 

jenkins-windows-slave-creation-4

5- Choose the appropriate Launch method

jenkins-windows-slave-creation-5

 

Below mentioned steps to configure and enable security are very important steps.

If you miss this you might not be able to start/configure the Jenkins slave because by default Jenkins disabled the TCP Port for JNLP agents and due to this Agent is not able to reach Master.

 

6 – Again click on Manage Jenkins

jenkins-windows-slave-creation-1

7- Then click on Configure Global Security

jenkins-windows-slave-creation-7

 

8- Find out the Enable Security option

jenkins-windows-slave-creation-8

9-  And then change the

jenkins-windows-slave-creation-9

10- Once the new node is created, it will be in Offline mode

jenkins-windows-slave-creation-10

11- Now click on the Slave agent

jenkins-windows-slave-creation-11

12- You will see Agent is not able to reach the master Jenkins and the new jnlp jar can be downloaded from Jenkins

 

jenkins-windows-slave-creations-12

13- Open the Jenkins URL from Agent Windows Machine and navigate to Slave Configuration page

Once done, just click on Launch Button – You will see a new popup which confirms the Jenkins Master-Slave Connection.

jenkins-windows-slave-creations-13

Lets now create and install this as a Windows service which will avoid the hassle to go to url and perform the same operation every time.

Once you create the service it will always be up & running and then you can manage it through Windows Services

14- Don’t close the pop-up, instead just click on File Menu – If its not visible just maximise the popup window

jenkins-windows-slave-creation-14

15- Now, just click on Install as a service option

jenkins-windows-slave-creation-15

 

16- It will prompt you for the confirmation

jenkins-windows-slave-creations-16

17- Just click on OK

jenkins-windows-slave-creation-17

18- Go to Windows Settings and then to check the Windows Services

jenkins-windows-slave-creation-18

19- You can see the Jenkins Windows Slave is successfully configure and running (If not then just Start the Service)

jenkins-windows-slave-creation-19

 

20- Go back to your Jenkins Slave Page and now you will see that Agent is Successfully Running and ready to build your project

jenkins-windows-slave-creation-20-done

Thats it. You have successfully configured the Jenkins Slave on Windows Machine and Installed it as a Windows Service.

33 comments… add one
  • Bhimsen Link Reply

    Hi Ravi,
    Very informative documentation. Appreciate your efforts.
    Can you please help me in setting up Windows slave server using launch method “Launch slave agents via ssh” instead of Java Web start?

    • Hi Bhimsen,
      Thanks for your feedback and sorry for delay in reply.
      The easiest way to connect windows slave is with Java Web start, however there are cases where you need to use ssh for some reasons.
      Have you considered and tried with Cygwin for Windows ? “https://wiki.jenkins.io/display/JENKINS/SSH+slaves+and+Cygwin” or Freesshd “http://www.freesshd.com/?ctt=overview” for the same ?

  • Bryan Calvo Link Reply

    Thanks.
    this guide worked 100% for me, thanks a lot

  • Ravi Kumar Link Reply

    Hi Ravi,
    Thanks for your information.
    When we click on “Launch” button, an authentication pop-up is showed, we put our admin login, then we have a Jenkins window , and after some seconds, we have an error-popup Java.io.Exception failed to connect………
    Can you please help me on this:)
    Thanks in advance,
    RaviKumar

  • Ravi Kumar Link Reply

    Hi Ravi,
    Thanks for your quick reply.
    The issue is not with the java version,as you mentioned in above screenshots i’m facing issue at step14 .
    After the jenkins slave pop-up i’m not finding the File Menu option to inastall as a service even maximized mode and after some time Error window pop-up appearing with the logs like..
    java.io.IOException:Failed to connect to URL:50000
    at org.jekinsci.remoting engine.JnlpAgentEndpoint.open(JnlpAgentEndpoint.java:242)…
    …..
    any suggessions!
    ThankYou

    • Did you try to check whether the port is accessible or not ?
      Have you made any changes to Iptables?
      By default, JNLP slave port configured as random – Have you tried with making fixed port or open Iptables over your firewall or configure port forwarding?
      If these also not working for you then, please share the network architecture of your master-slave connectivity and error logs.

    • Also, you can install the service with an alternative method described in my previous article
      https://scmquest.com/jenkins-file-menu-missing/

  • Rashmi Link Reply

    Hi,

    When I clicked on Launch button from my agent, I see slave-agent jnlp file getting downloaded. I dont see any popup for making my agent as slave. What do I do now?

    Thanks,
    Rashmi

    • Hi Rashmi,
      Thanks for your query.
      Have you checked the browser settings (it should not block pop-ups), I would suggest to try on other browsers as well (IE, Firefox, Chrome, etc)
      However you can also make your agent as Jenkins slave through command line :

      Just run the below command with correct parameters as per your installation from your slave path:

      $ java -jar slave.jar -jnlpUrl http://yourserver:port/computer/slave-name/slave-agent.jnlp (You can refer the full command which should be displayed on your launch screen)

      Please make sure you are running this command from the location where the slave.jar was copied.

      If you see any error in download/ or fail to download – you can get the copy of your slave.jar from http://yourserver:port/jnlpJars/slave.jar

      Hope this helps and resolves your issue

  • Nan Link Reply

    Ravi,

    Thanks a lot. It saved me hours of troubleshooting.

    Nan

  • susmit Link Reply

    Hi,
    My slave machine is unable to reach to my masters as the port is not reachable.
    It was working till yesterday, I am not sure how to change the port number. I have created a Jenkins as a service(JAAS)

    • Hi Susmit,

      Thanks for your query. You first should find out the root cause of the issue.

      Assuming both your Jenkins master and slaves are on Windows

      Check jenkins master’s & slave’s logs for details

      Then check windows logs through Event Viewer

      You can open Jenkins.xml to verify which port is used by Master

      Try to see if Jenkins is still listening to that port
      On Command Prompt : netstat -ano | findStr “portnumber”

      Use netsh to define the incoming/outgoing ports

      You can also verify the master-slave connection as suggested in oficial article

      1- Use jenkins-cli to check the connection
      In the slave box download http://JENKINS_URL/jnlpJars/jenkins-cli.jar from Jenkins master and execute the command below:

      java -jar jenkins-cli.jar -s http://JENKINS_URL/ –username=USERNAME –password=PASSWORD help

      Check that the JNLP port and hostname are right

      2- Launch the commands below and check that the port and hostname are the right ones:

      curl -I http://JENKINS_URL/computer/SLAVE-Host/slave-agent.jnlp
      curl -I http://JENKINS_URL/tcpSlaveAgentListener/

      In case you suspect you have a firewall between the master and the slave, you need to configure the port number under JenkinsMasterURL/configureSecurity

      Check if that works.

  • saicharan Link Reply

    Hi,
    How to run slaves and master run same job at a time

    Thanks,
    saicharan

    • Hi Saicharan,

      Thanks for your query – I am assuming you are looking for the solution to run same job on multiple nodes (including master) at same time.
      This is achievable through “NodeLabel Parameter Plugin” – The official document (https://wiki.jenkins.io/display/JENKINS/NodeLabel+Parameter+Plugin) demonstrate it in very simple way, just go through it and let me know in case of any query.

      Happy questing !!

  • Krishna Link Reply

    Hi Ravi,
    I’ve followed the same steps in the above article, but my slave agent is still offline. If I launch the slave agent using Java web start, then it’s working fine. But when I install it as service, it’s going offline. Even remoting log says nothing.
    Please help!
    Thanks.

    • Hi Krishna,
      Thanks for your query.
      Hope you have configured the service as “Local system user” ?
      And if you are not getting the “File” menu then please refer https://scmquest.com/jenkins-file-menu-missing/
      Do let me know in case of any issue

      • Krishna Link Reply

        Thank you Ravi for the prompt reply. I could see the ‘File’ menu, and could install the service as an admin. But still the agent shows offline. My slave machine is in a private network behind firewall and port 50000 is open for communication. Did I miss anything ?

        • Hi Krishna,
          Since you can use Java web start method without any issue, it shouldn’t be an issue of firewall.
          Can you please change the service “Log on as” : Local System account and verify if that works ?

          • Krishna Link

            Hi Ravi,
            I’ve tried running service as Local System User. Unfortunately, the slave agent is offline. I’ve noticed an error in Event Viewer, it says ‘Failed to download https:///jnlpJars/slave.jar to \slave.jar’. Is that any clue to find the cause ?

          • Hi Krishna,
            When you download the slave.jar as mentioned in Step 13. Are you getting a pop-up which confirms connection ?
            Are you getting “File” menu in the popup ?
            Are you getting “Install as a service” option ?
            Can you locate newly installed service (if you get the option) in Services ?

            You can also install service from command prompt, please refer https://scmquest.com/jenkins-file-menu-missing/
            Let me know if you still get any issue

  • Krishna Link Reply

    Hi Ravi,
    I appreciate your prompt response. As mentioned in step 13, when I click on Launch button, slave.jar is being downloaded. A pop up asking for connection appearing and I could make connection. I could even see File menu and Install as service option. When I install as service, the pop up is closing and agent is going offline. Hope you understand my problem.
    Thanks.

    • Krishna Link Reply

      To add to the above, I could locate the service in windows services.msc. I am using ‘Local System Account’ as Log on option of the jenkins service. The issue still persists. Agent is offline.

      • Hi Krishna,
        Are you getting a confirmation pop-up as mentioned in step 16 ?
        If yes, then can you uninstall the installed service and try with manual step once as described in https://scmquest.com/jenkins-file-menu-missing/
        please let me know the outcome

        • Krishna Link Reply

          Hi Ravi,
          Thank you for your support all the way. I’ve sorted the issue by myself. I have seen an error in Event viewer after setting up windows service. The error is related to downloading slave jar file. Since my machine is behind firewall, I had to open port related to HTTP in firewall and repeated the above mentioned steps by you. I’m sharing this so that it might help someone like me.
          Thank you for the blog by the way. I liked it. Keep sharing the learning 🙂
          Cheers.

          • Hi Krishna,
            Thanks for sharing your feedback and glad you were able to resolve the issues.
            You earlier said you were able to run the slave but were not able to set the service and that’s the reason i commented that it doesn’t seems to be a firewall issue, but happy you manage to sort it out.
            Keep questing !!

  • Krishna Link Reply

    Hi Ravi,
    I’ve encountered a new issue after setting up windows service. My jenkins build job is unable to clone github repo now. But if I stop the service and connect via ‘Java web start’ it is working as usual. Do you know why it is happening ? Could you help sort this out ?
    Thanks.

  • zonoco Tim Link Reply

    This Jenkins instance uses deprecated protocols: JNLP-connect,JNLP2-connect,JNLP3-connect. It may impact stability of the instance. If newer protocol versions are supported by all system components (agents, CLI and other clients), it is highly recommended to disable the deprecated protocols. See Protocol Configuration

    Hi,guy
    I has setup a win10 slave on Jenkins 2.176.1,but there is a warning.
    Then,which launch method can I use?and how configure it?

    Sorry for I cannot find the post date of this article,maybe is too old and you do not attention it long times.

    • zonoco Tim Link Reply

      OK,just disable JNLP-connect and 2 \3,the warning msg gone.

  • Sakshi Link Reply

    My master in Linux server and I am setting Slave as Windows.
    I am getting this error : java.io provided port 35107 is not reachable.

Leave a Comment