Jenkins Master-Slave setup and configuration with screenshots

Howdy friends ….

As promised in our Jenkins Installation & Configuration article, here we are with the configuration of Jenkins Master-Slave setup.

We have already learnt about Jenkins Installation and basic Configuration along with setting up our first project and running a build for the same.

Jenkins supports the master-slaves architecture, i.e. many slaves works for a master. It is also known as Jenkins Distributed Builds.

Jenkins_Master_Slaves

A Jenkins master comes with the basic installation of Jenkins and in this configuration the master handles all tasks for your build system.

Now, someone might thinks whether they really need this Jenkins slave or they can run their project without it ?

True, its not mandatory to have Jenkins client, Your master Jenkins can also create the build (what we did in our last article)

But, that will sustain just for small projects where they have very less jobs (say 5-10 job in a day and that too not very frequent)

When, you are working with numbers of projects and wants to run multiple jobs – You need to configure slaves/aagents to serve this purpose.

Jenkins slaves/agents are nothing just a small Java “Client” processes that connects to the “Master” Jenkins instance over the Java Network Launch Protocol (JNLP).

Jenkins Master role is to schedule the build jobs, assign slaves/agents and send builds to the slaves for the actual execution.

It also monitor the slaves (taking them online and offline as and when required), getting back the response of the build results from slaves then showing the build results on console.

All of the job results are collated on the master node for easy viewing.

With this approach of Jenkins master-slaves, the actual workload of building projects are delegated to multiple “slave” nodes, which allows to run numerous projects and their jobs.

It will also allow you to run jobs on different environments, like Linux, Windows, MacOS, etc (as shown in above image).

You might need to run same test case on different environments in parallel, that is where this distributed approach helps you to achieve the desired results quickly.

Once you configures few Jenkins slaves/agents, you might remove the executors on the Jenkins master in order to free up Jenkins master resources, but this isn’t necessary.

You can install and configure several Jenkins Slaves/Agents on 1 machine considering its input/output, cpu, disk & memory states.

Having multiple slaves will allow you to work more quickly without wasting time on waiting for build executors.

So, lets proceed with setting up a slave/agent/client for our Jenkins Master.

First, check whether you have Java installed or not. (If not then install it in similar fashion how we have installed during Jenkins installation)

Go to Jenkins dashboard -> Manage Jenkins -> Manage Nodes.

jenkins_manage_plugins_page

jenkins_node_configuration_step0

Name the node and click on OK.

* Initially you will get only one option “Permanent Agent” or “Dumb Slave“(in earlier jenkins versions), but once you have one slave then you will get another option to copy the node from another node which named as “Copy Existing Node

jenkins_node_configuration_step11

You will get the node configuration page where you need to enter required details. Not all the details are mandatory but it would be good practice to enter as much information as you can so that another team member can get all the idea without troubling you.

jenkins_node_configuration_step55

Lets go through with all the parameters in the node configuration page as displayed above :

Name : Name of the Slave which should be unique.

Description : Optional , Description for this slave, but as I said earlier, it would be really helpful for other team members

# of executors : The maximum number of concurrent builds that Jenkins may perform on this agent. I have used just 1 executor for testing purpose, but a good value to start with would be the number of CPU cores on the machine. You can check the server stat and then define the number of executors.

Remote root directory : An agent needs to have a directory dedicated to Jenkins. Specify the path to this directory on the agent. It is best to use an absolute path, such as /var/jenkins/node1 or c:\jenkins\node1. This should be a path local to the agent machine. There is no need for this path to be visible from the master.

Labels : Labels (or tags) are used to group multiple agents into one logical group. Multiple labels must be separated by a space. For example, linux docker would assign two labels to the agent: linux and docker.

Usage : Controls how Jenkins schedules builds on this node. Utilize this node as much as possible- This is the default and normal setting. In this mode, Jenkins uses this node freely

Launch method : It Controls how Jenkins starts this agent.

– Launch agent via Java Web Start: It allows slave to be launched using Java Web Start. In this case, a JNLP file must be opened on the agent machine, which will establish a TCP connection to the Jenkins master. This means that the agent need not be reachable from the master; the agent just needs to be able to reach the master. If you have enabled security via the Configure Global Security page, you can customize the port on which the Jenkins master will listen for incoming JNLP agent connections.
By default, the JNLP agent will launch a GUI, but its also possible to run a JNLP agent without a GUI, e.g. as a Window service.

– Launch agent via execution of command on the master: It starts slave by having Jenkins execute a command from the master. Use this when the master is capable of remotely executing a process on another machine, e.g. via SSH or RSH.

– Launch slave agents via SSH: It starts a slave by sending commands over a secure SSH connection. The slave needs to be reachable from the master, and you will have to supply an account that can log in on the target machine. No root privileges are required. This is the one which i am using for my slave configuration.

— Host Key Verification Strategy : Controls how Jenkins verifies the SSH key presented by the remote host whilst connecting.

— Known Host file verification strategy : Checks the known_hosts file (~/.ssh/known_hosts) for the user Jenkins is executing under, to see if an entry exists that matches the current connection.

{ If you are getting a SSH Host Key Verification error as below:

No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
java.io.IOException: There was a problem while connecting to node2.devopsbuzz.com/

It could be a problem with SSH lib used by Jenkins which does not support newer ciphers like ecdsa-sha2-nistp256. Just delete the known_hosts entry and create a new one through below command

ssh -o HostKeyAlgorithms=ssh-rsa node2.devopsbuzz.com/      (where node2.devopsbuzz.com/ is the hostname of the slave server)

It will solve your problem.  }

— Manually provided key verification strategy : Checks the key provided by the remote host matches the key set by the user who configured this connection.

— Manually trusted key verification strategy : Require a user with Computer.CONFIGURE permission to authorise the key presented during the first connection to this host before the connection will be allowed to be established.

— Non Verifying verification strategy : Does not perform any verification of the SSH key presented by the remote host, allowing all connections regardless of the key they present. Its not advisable to select as it may open the path for attackers.

– Let Jenkins control this Windows slave as a Windows service: It starts a Windows slave by a remote management facility built into Windows. Suitable for managing Windows slaves. Slaves need to be IP reachable from the master.

Availability : Controls when Jenkins starts and stops this agent.

Keep this slave on-line as much as possible : This one is the default and normal setting. In this mode, Jenkins tries to keep the slave on-line as much as possible. If Jenkins can start the slave without user assistance, it will periodically attempt to restart the slave if it is unavailable. Jenkins will not take the slave off-line.

Take this slave on-line when in demand and off-line when idle : In this mode, if Jenkins can launch the slave without user assistance, it will periodically attempt to launch the slave while there are unexecuted jobs else the slave will be taken off-line by Jenkins

You can also define the node properties, like environment variables, such as PATH, JAVA_HOME, etc and Tools locations such as, ANT, GIT, etc.

jenkins_node_configuration_step4

Environment variables defined here will be made available to every build executed by this agent, and will override any environment variables that have the same Name as those defined on the Configure System page.

For Tool Locations, you can specify the location of certain tools on this node, overriding the global configuration (You may prefer to use automatic tool installers instead, removing the need to configure each node separately)

Once you are done click on SAVE and that’s it. Your new Jenkins Slave is up and running and ready to take the builds

jenkins_node_status01

Now, lets go ahead and run our first build on this slave.

As I have mentioned and you might have noted that Jenkins master do have their build executors and until we turn them off, Jenkins can use those executors to perform builds based on the CPU stats, memory and other factors. So to avoid this issue we need to do some changes in our project configuration to force the project’s job to run on newly created Jenkins Slave.

This technique is also helpful when you have some jobs to be run on different platforms, with specific configurations, etc (like we discussed in the beginning of this article)

So, to configure the project specific to this new node,

Open the Project and click on Configure

jenkins_node_run1

Find the check-box in General section “Restrict where this project can be run” and click on it

jenkins_node_run2

Just type the Label name of your slave, in this case its “node1”

jenkins_node_run3

And then Save the changes.

Go back again to Your Project and click on “Build with Parameters

jenkins_node_run1

Choose the appropriate parameter(s) [Based on your project configurations] and click on Build

jenkins_node_run4

Then click on Build number and check the Console Output, where you will find that build is running on newly created node and is successful

jenkins_node_run5

You can also check the Node statistics to get all the idea about the newly created node/slave/agent.

jenkins_node_run6

You can also define more than one labels (i.e. more than one node to the project) which will allow you to run the build in parallel and Jenkins will choose the faster slave for your build. To do that,

Go back to Project Configuration and find the “Restrict where this project can be run” option. Click on Help for feature: This project is parameterised button to know all the expression details

jenkins_node_configuration_step7

You can use || symbol to tell Jenkins to use any of the slave, like below

jenkins_node_configuration_step8

Once done, Save your changes and again go back to Your Project and click on “Build with Parameters“. And this time you will find the job ran on master build executor since we have given a choice to Jenkins to choose any build executor of master or slave (node1)

jenkins_run2

Congratulations !! You have successfully added the new Jenkins Slave/Agent/Node and configured project accordingly.

In today’s article we have covered:

  • Need of Jenkins Slave/Agent
  • Concept of Distributed Build
  • Jenkins Slave/Agent configuration
  • Issue with SSH Host Key Verification and its resolution
  • Jenkins Project changes to run job on particular node
  • Build on Jenkins Agent

Hope you enjoyed our article and got more idea about Jenkins.

We will come with some new topic, till then stay tuned ….

61 thoughts on “Jenkins Master-Slave setup and configuration with screenshots”

  1. I was actually waiting for this master-slave setup after reading your previous article on Jenkins installation. Thanks a bunch !!

  2. Thanks for this wonderful article, it has actually helped me to configure my jenkins node on linux machine but I am facing error with windows jenkins node, can you please write on that as well ?

  3. You cover the node configuration well but I quickly read the article 3 times and still can’t see you mention how to install the client on the remote machine?

    1. Hi Tom,
      Sorry for delayed response.
      If you are using *nix machines, you don’t have to install the jenkins client on Slave (i.e. slave.jar on slave node), instead Jenkins will take care of this part once you Launch the agent.

  4. Thanks very much. This is an excellent article providing insight into the Master-Slave concept of Jenkins.

  5. Hello,

    I have installed Jenkins server on windows server and I have repos on GIT Server.

    I want to deploy php and some file on windows server.

    Can anyone help me how to add windows client in jenkins and deploy code on windows. which plugins is suitable and also share if any links.

  6. Hi Ravi,
    Thanks for this post, I had a common case, the jenkins server is installed on Mac and we have ASP.NET project, so we need to build ASP.NET project via dotnet build tool on another Windows machine (a Node), so how I can execute dotnet build tool or cmd on that Windows Node? Thank you.

    1. Hi Su,
      Thanks for your query.
      You can refer the article https://devopsbuzz.com/jenkins-windows-slave-configuration-with-screenshots/ for configuring windows slave
      Once it is configured you can tied the new windows node to your ASP.Net project and use msbuild, etc for building the project.
      In order to use MSBuild, you need to install the plugin
      – Click the “Configure System” through “Manage Jenkins”
      – Search for “MSBuild”
      – Click on “MSBuild installations”
      – then click “Add MSBuild”
      – Make sure to give the fully qualified path to msbuild.exe in path field

      Once that is done:
      -Navigate to your “Project”
      -Select “Configure”
      -Go to “Add build step”
      -Select “Build a Visual Studio project or solution using MSBuild” option
      -For other commands you can use : Select “Execute Windows batch command”

      And you are good to go
      Hope it helps and do let me know in case of any issue.

    1. Hi Rinku,
      Thanks for your query.
      The default value of # of Executors for the slave is : 1, when you don’t edit the value.
      You can also refer the documentation for this field by clicking on question mark info symbol found next to field
      “Agents must have at least one executor. To temporarily prevent any builds from being executed on an agent, use the Mark this node temporarily offline button on the agent’s page.
      This does not apply to the Jenkins master — setting the number of executors to zero will prevent any builds from being executed on the master.”

      And if you edit this value to 0 for Slave/Agent Node – It will throw the error as “Invalid agent configuration for ‘agentname’ Invalid # of executors.”

      As I highlighted in the article, a good value to start with would be the number of CPU cores on the machine. You can check the server stat and then define the number of executors.
      Hope this helps ..

  7. We need to deploy war file in a centralized system, in KIOSK machine we are deploying war file in each system, how to resolve this issue , we are looking for a deployment centrally and all nodes in same network can access that.

    1. Hi Abhay,
      Thanks for posting your query.
      Please can you provide more details:
      – What is the input (tools, technology, build tool, etc)
      – What is an expected outcome ( Build output, App/Web Servers, Deployment type, Clusters/ Node statistic, etc)
      – Your Network Topology
      – Issue you are facing with debug output.

      Will then go through with your issues and try to resolve/suggest the solution

  8. Hi Ravi,
    Thank you for your efforts and keeping such nice articles.
    I would like to take your guidance to expertise in Jenkins with knowledge and real time experience.
    I have been working working as part of Cloud and DevOps project where as we have only limited scope and I am very much interested and like Jenkins.
    Could you please help me.
    Regards,
    Sathish Kumar

    1. Hi Sathish,
      Thanks for your feedback.

      Basically, Jenkins helps to automate the Software development processes with CI-CD.Jenkins functionality can be extended with plugins.Jenkins can be installed/confgured very easily to fulfill your requirements.You can run any kind of job, and automate the process with simple view.It integrates with several other tools very well to provide the best outcome in less time with minimal efforts.You can run a cron job (scheduled), on commit build, deployment on successful build, database transaction, manual build, automated testing job, orchastration, server provisioning job, and so on.

      I would request you to create a test project/ pipeline and try as many combinations you can and integrate with different tools which you are using in your organisation. It will help you understand the functionality in depth.
      As per my experience, I always learn something new as and when any issue arrives. You might not face an issue while managing it but it would be very helpful to enhance the knowledge & understanding.

      Jenkins has maintained a very well tutorial within it which you might find useful https://jenkins.io/doc/tutorials/

      And when you face any issue try to search this website and if you didn’t get exact answer, please feel free to drop a comment and I will try to get back to you as soon as i can.

      Keep questing !!

      1. Hi Ravi,
        Thanks for your valuable suggestion and guidance.
        I need a help, I am trying to run an Ansible playbook from Jenkins and I did configure the Job after installing Ansible plugin. Noticed, Job is executing by Jenkins so would like to make this Job to run by a dedicated user like ansadm… could you please suggest me is it possible or anything should run under Jenkins?

        Regards,
        Sathish Kumar

  9. Hi Ravi,
    Thanks for your valuable suggestion and guidance.
    I need a help, I am trying to run an Ansible playbook from Jenkins and I did configure the Job after installing Ansible plugin. Noticed that Job is executing by Jenkins user so would like to make this Job to run by a dedicated user like ansadm… could you please suggest me is it possible or anything should run under Jenkins user?

    Regards,
    Sathish Kumar

      1. Hi Ravi,

        Thanks for response.
        could you help me with some documentation on setting up executor to run Jobs, I found few but seems not giving relevant info.

        Regards,
        Sathish Kumar

        1. Hi Sathish,
          I added a new Node named as ansible to my Jenkins. I used an Ubuntu machine as Slave machine and used my name as Username.
          On the Ubuntu machine (slave), I created my user name and configured it to upload & install the slave.jar on initial setup.

          I used “Launch method” as “Launch Slave agents via SSH”, Provide Host IP and my user’s credentials (You can use Windows service option with ansible user for Windows connection as well)

          Once the new node configured successfully, I installed Ansible on Slave node server and created a test playbook on the same server.

          Then I configured Jenkins job to test the connectivity and user name.

          My test playbook:
          ———————————————
          ravi@:~/ansible$ more ansible.yml

          – hosts: localhost
          tasks:
          – name: get the username running the deploy
          local_action: command whoami
          register: username_on_the_host
          – debug: var=username_on_the_host

          – name: Print message
          debug: msg=”Hello from Ansible!!”
          —————————————–

          Jenkins job output
          —————————————–
          Started by user Admin
          Building remotely on ansible in workspace /home/jenkins/workspace/test
          [test] $ /usr/bin/ansible-playbook /home/ravi/ansible/ansible.yml -f 5
          [WARNING]: provided hosts list is empty, only localhost is available. Note
          that the implicit localhost does not match ‘all’

          PLAY [localhost] ***************************************************************

          TASK [Gathering Facts] *********************************************************
          ok: [localhost]

          TASK [get the username running the deploy] *************************************
          changed: [localhost -> localhost]

          TASK [debug] *******************************************************************
          ok: [localhost] => {
          “username_on_the_host”: {
          “changed”: true,
          “cmd”: [
          “whoami”
          ],
          “delta”: “0:00:00.280720”,
          “end”: “2018-11-01 21:49:33.859870”,
          “failed”: false,
          “rc”: 0,
          “start”: “2018-11-01 21:49:33.579150”,
          “stderr”: “”,
          “stderr_lines”: [],
          “stdout”: “ravi”,
          “stdout_lines”: [
          “ravi”
          ]
          }
          }

          TASK [Print message] ***********************************************************
          ok: [localhost] => {
          “msg”: “Hello from Ansible!!”
          }

          PLAY RECAP *********************************************************************
          localhost : ok=4 changed=1 unreachable=0 failed=0

          Finished: SUCCESS
          —————————————–

          Hope you would be able to resolve the issue now – Let me know your feedback

          1. Hi Ravi,

            Thank you for your detailed information, its very useful.
            I spin up one new EC2 instance to dedicate to Ansible where I have setup Ansible on this node. I am using new user as ansadm, I setup this new user in both the servers Master Jenkins and Slave node (Ansible) server and generated new ssh keys (ssh-keygen utility) and copied pub keys to slave node (Ansible node) using ssh utility ssh-copy-id ansadm@slaveserverip and in Jenkins UI under Credentials ->Global credentials-> Add credentials for ansadm copied private key of ansadm from Jenkins master server and saved it.

            In the Add new node, add this slave node (Ansible) and chose options as Launch agent agents via ssh but getting below error some how:

            SSHLauncher{host=’172.31.89.51′, port=22, credentialsId=’9985a430-d2dc-418f-a309-13ac66d3fe50′, jvmOptions=”, javaPath=”, prefixStartSlaveCmd=”, suffixStartSlaveCmd=”, launchTimeoutSeconds=210, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
            [11/02/18 14:49:15] [SSH] Opening SSH connection to 172.31.89.51:22.
            [11/02/18 14:49:15] [SSH] The SSH key presented by the remote host does not match the key saved in the Known Hosts file against this host. Connections to this host will be denied until the two keys match.
            Key exchange was not finished, connection is closed.

            I am going through your blog and understand that need to add pub keys of ansadm with slave server IP in known_hosts file, I did updated under Jenkins and ansadm ~/.ssh/known_hosts file in the Master Jenkins server but issue remains same.

            Could you please help me where I am missing the flow and I am not understanding in which server known_hosts to copy the keys with slave IP.

            Regards,
            Sathish Kumar

          2. Hi Sathish,

            Please find the below steps which I followed :

            Provisioned new instance and added user
            ubuntu@ip-XXX-XX-XX-XXX:~$ sudo adduser ravi
            Created ssh key
            ravi@ip-XXX-XX-XX-XXX:~$ ssh-keygen
            Press Enter and Enter

            Checked the user created
            ubuntu@ip-XXX-XX-XX-XXX:~$ grep ravi /etc/passwd
            ravi:x:1001:1001:Ravi,123,89213123213,,SCM:/home/ravi:/bin/bash
            Added entry
            ubuntu@ip-XXX-XX-XX-XXX:~$ sudo vi /etc/ssh/sshd_config
            Restarted service
            ubuntu@ip-XXX-XX-XX-XXX:~$ sudo service sshd reload
            Provided sudo to my user since its blocked instance
            ubuntu@ip-XXX-XX-XX-XXX:~$ sudo usermod -a -G sudo ravi
            ubuntu@ip-XXX-XX-XX-XXX:~$ sudo visudo -f /etc/sudoers

            Logined through new user and install Java then Ansible
            ravi@ip-XXX-XX-XX-XXX:/etc/init.d$ sudo apt-get install
            ravi@ip-XXX-XX-XX-XXX:/etc/init.d$ sudo apt-get install default-jre
            ravi@ip-XXX-XX-XX-XXX:/etc/init.d$ java -version
            ravi@ip-XXX-XX-XX-XXX:/etc/init.d$ sudo apt-get install ansible
            Check Ansible
            ravi@ip-XXX-XX-XX-XXX:/etc/init.d$ ansible
            ravi@ip-XXX-XX-XX-XXX:~/ansible$ which ansible
            /usr/bin/ansible
            Created playbook
            ravi@ip-XXX-XX-XX-XXX:~/ansible$ chmod 700 ansible.yml
            Create Jenkins remote root directory
            /Users/Shared/Jenkins/Home/workspace/

            On Jenkins server I created new node
            I used “Launch method” as “Launch Slave agents via SSH”, Provide Host IP and my user’s credentials

            For Testing purpose I used:
            Host Key Verification Strategy : Non Verifying Verification Strategy

            And then clicked on “Launch Agent” which has launched agent on Ubuntu server

            Configure this agent as “Restricted to” in your Anisble project

            And then Build my Job to run the Ansible playbook

  10. I have Installed jenkins version 2.164 on one of my windows machine.
    Also have brought many machines onine on it. But it so happens that if the node is idle then it gets offline.
    even in node set up my availability option selected is “Keep node online as much as possible.”
    logs
    Jul 09, 2019 1:15:08 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Terminated
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Performing onReconnect operation.
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: onReconnect operation completed.
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Locating server among [http://whf00gbx.in.oracle.com:8080/]
    Jul 09, 2019 1:15:18 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver
    resolve
    INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Agent discovery successful
    Agent address: whf00gbx.in.oracle.com
    Agent port: 49467
    Identity: ad:1f:a7:df:16:4e:8f:9f:cd:ee:bf:0e:e4:70:24:97
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Handshaking
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Connecting to whf00gbx.in.oracle.com:49467
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Trying protocol: JNLP4-connect
    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Remote identity confirmed: ad:1f:a7:df:16:4e:8f:9f:cd:ee:bf:0e:e4:70:24:97

    Jul 09, 2019 1:15:18 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Connected
    Jul 09, 2019 11:40:52 AM org.jvnet.winp.Native loadByUrl
    WARNING: Failed to load DLL from static location
    java.lang.UnsatisfiedLinkError: Native Library C:\newjenkins\remoting\jarCache\1
    2\winp.x64.BD89A6734D0147A7868D1B98DB8EF12D.dll already loaded in another classl
    oader
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at org.jvnet.winp.Native.loadDll(Native.java:243)
    at org.jvnet.winp.Native.loadByUrl(Native.java:163)
    at org.jvnet.winp.Native.load(Native.java:125)
    at org.jvnet.winp.Native.(Native.java:94)
    at org.jvnet.winp.WinProcess.enableDebugPrivilege(WinProcess.java:245)
    at hudson.util.ProcessTree$Windows.(ProcessTree.java:674)
    at hudson.util.ProcessTree.get(ProcessTree.java:427)
    at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1097)
    at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1088)
    at hudson.remoting.UserRequest.perform(UserRequest.java:212)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:369)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecut
    orService.java:72)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
    at java.lang.Thread.run(Unknown Source)

    Jul 10, 2019 3:28:54 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Terminated
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Performing onReconnect operation.
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: onReconnect operation completed.
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Locating server among [http://whf00gbx.in.oracle.com:8080/]
    Jul 10, 2019 3:29:04 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver
    resolve
    INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Agent discovery successful
    Agent address: whf00gbx.in.oracle.com
    Agent port: 49467
    Identity: ad:1f:a7:df:16:4e:8f:9f:cd:ee:bf:0e:e4:70:24:97
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Handshaking
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Connecting to whf00gbx.in.oracle.com:49467
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Trying protocol: JNLP4-connect
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Remote identity confirmed: ad:1f:a7:df:16:4e:8f:9f:cd:ee:bf:0e:e4:70:24:97

    Jul 10, 2019 3:29:04 AM org.jenkinsci.remoting.protocol.impl.ConnectionHeadersFi
    lterLayer onRecv
    INFO: [JNLP4-connect connection to whf00gbx.in.oracle.com/10.40.73.78:49467] Loc
    al headers refused by remote: WHF00DWA is already connected to this master. Reje
    cting this connection.
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Protocol JNLP4-connect encountered an unexpected exception
    java.util.concurrent.ExecutionException: org.jenkinsci.remoting.protocol.impl.Co
    nnectionRefusalException: WHF00DWA is already connected to this master. Rejectin
    g this connection.
    at org.jenkinsci.remoting.util.SettableFuture.get(SettableFuture.java:22
    3)
    at hudson.remoting.Engine.innerRun(Engine.java:614)
    at hudson.remoting.Engine.run(Engine.java:474)
    Caused by: org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException: WHF0
    0DWA is already connected to this master. Rejecting this connection.
    at org.jenkinsci.remoting.protocol.impl.ConnectionHeadersFilterLayer.new
    AbortCause(ConnectionHeadersFilterLayer.java:378)
    at org.jenkinsci.remoting.protocol.impl.ConnectionHeadersFilterLayer.onR
    ecvClosed(ConnectionHeadersFilterLayer.java:433)
    at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(Protoc
    olStack.java:816)
    at org.jenkinsci.remoting.protocol.FilterLayer.onRecvClosed(FilterLayer.
    java:287)
    at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.onRecvClose
    d(SSLEngineFilterLayer.java:172)
    at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(Protoc
    olStack.java:816)
    at org.jenkinsci.remoting.protocol.NetworkLayer.onRecvClosed(NetworkLaye
    r.java:154)
    at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer.access$1500(BION
    etworkLayer.java:48)
    at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader.run(BIONe
    tworkLayer.java:247)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
    at java.lang.Thread.run(Unknown Source)
    Suppressed: java.nio.channels.ClosedChannelException
    … 7 more

    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Connecting to whf00gbx.in.oracle.com:49467
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Server reports protocol JNLP4-plaintext not supported, skipping
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Server reports protocol JNLP3-connect not supported, skipping
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Server reports protocol JNLP2-connect not supported, skipping
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Server reports protocol JNLP-connect not supported, skipping
    Jul 10, 2019 3:29:04 AM hudson.remoting.jnlp.Main$CuiListener error
    SEVERE: The server rejected the connection: None of the protocols were accepted
    java.lang.Exception: The server rejected the connection: None of the protocols w
    ere accepted
    at hudson.remoting.Engine.onConnectionRejected(Engine.java:682)
    at hudson.remoting.Engine.innerRun(Engine.java:639)
    at hudson.remoting.Engine.run(Engine.java:474)

      1. Hi Ravi,

        I face the similar problem and I have upgrade Jenkins version to 2.263.1.
        Would you please advise? Many thanks!

        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Connecting to ahknts70:52005
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Trying protocol: JNLP4-connect
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Remote identity confirmed: 8e:d7:1a:93:a5:9b:dc:ad:45:fe:d2:4e:b7:ee:39:12
        Jan 07, 2021 7:30:36 PM org.jenkinsci.remoting.protocol.impl.ConnectionHeadersFilterLayer onRecv
        INFO: [JNLP4-connect connection to ahknts70/10.1.6.70:52005] Local headers refused by remote: vvs10w7_64w1 is already connected to this master. Rejecting this connection.
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Protocol JNLP4-connect encountered an unexpected exception
        java.util.concurrent.ExecutionException: org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException: vvs10w7_64w1 is already connected to this master. Rejecting this connection.
        at org.jenkinsci.remoting.util.SettableFuture.get(SettableFuture.java:223)
        at hudson.remoting.Engine.innerRun(Engine.java:609)
        at hudson.remoting.Engine.run(Engine.java:469)
        Caused by: org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException: vvs10w7_64w1 is already connected to this master. Rejecting this connection.
        at org.jenkinsci.remoting.protocol.impl.ConnectionHeadersFilterLayer.newAbortCause(ConnectionHeadersFilterLayer.java:378)
        at org.jenkinsci.remoting.protocol.impl.ConnectionHeadersFilterLayer.onRecvClosed(ConnectionHeadersFilterLayer.java:433)
        at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(ProtocolStack.java:832)
        at org.jenkinsci.remoting.protocol.FilterLayer.onRecvClosed(FilterLayer.java:287)
        at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.onRecvClosed(SSLEngineFilterLayer.java:172)
        at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(ProtocolStack.java:832)
        at org.jenkinsci.remoting.protocol.NetworkLayer.onRecvClosed(NetworkLayer.java:154)
        at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer.access$1500(BIONetworkLayer.java:48)
        at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader.run(BIONetworkLayer.java:247)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
        at java.lang.Thread.run(Unknown Source)
        Suppressed: java.nio.channels.ClosedChannelException
        … 7 more

        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Connecting to ahknts70:52005
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Server reports protocol JNLP4-plaintext not supported, skipping
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Server reports protocol JNLP3-connect not supported, skipping
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Server reports protocol JNLP2-connect not supported, skipping
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener status
        INFO: Server reports protocol JNLP-connect not supported, skipping
        Jan 07, 2021 7:30:36 PM hudson.remoting.jnlp.Main$CuiListener error
        SEVERE: The server rejected the connection: None of the protocols were accepted
        java.lang.Exception: The server rejected the connection: None of the protocols were accepted
        at hudson.remoting.Engine.onConnectionRejected(Engine.java:670)
        at hudson.remoting.Engine.innerRun(Engine.java:634)
        at hudson.remoting.Engine.run(Engine.java:469)

        1. Hi Cindy,
          Sorry for delay in reply.
          Can you please let me know, if:
          – Jenkins is running behind the load balancer?
          – running on containerised environment (swarm/k8s)?
          – is there any default time limit set to reconnect ?

          Thanks in advance

          1. Hi Ravi,
            So happy to have your reply.
            – Jenkins is running behind the load balancer?
            [cindy] I think it should be, since our jenkins infrastructure across countries, it should have something kind like load balancer.
            – running on containerised environment (swarm/k8s)?
            [cindy] no
            – is there any default time limit set to reconnect ?
            [cindy] we use the default timeout setting, maybe 6min (I am not sure where and when I glanced this setting)

            Many thanks Ravi!

          2. From the limited logs, it seems that the socket communication between the master and the slave is simply lost without master’s knowledge. And when slave tries to connects back then the master refuses this attempt since the slave is already connected.

            Local headers refused by remote: vvs10w7_64w1 is already connected to this master. Rejecting this connection.

            Also, worth to know :
            – whether all the slaves gets disconnected or only few ?
            – was this started after the upgrade ?
            – is there any time difference between master’s & slave’s (ntp setting) ?
            – does it happen during restart or anytime ?

            Can you please set the below mentioned system property temporarily through Jenkins Script Console ( https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console) – to check if it resolves the issue, if yes then you can add this property “-Dhudson.slaves.ChannelPinger.pingIntervalSeconds=120” in your Jenkins (setting 2 mins – Default is 5 mins https://www.jenkins.io/doc/book/managing/system-properties/) – Try with different values if this is not working

            System.setProperty("hudson.slaves.ChannelPinger.pingIntervalSeconds", "120")

  11. My sincere thanks to everyone who is behind this effort in sharing the article and helping lots of people new to jenkins 🙂

  12. Hi,

    Thanks for this detailed doc. I just wanted to know, is it possible to setup a CentOS vm and configure multiple docker slaves on it? If it is feasible, can we setup those docker slaves runtime?

    Thanks,
    Mukesh

  13. If Jenkins salve is installed as a service in windows and master jenkins is on VM which is a linux, can installed slave(which is running as a service) in local desktop can remain online even the system is locked?

    1. Yes, that’s correct. As long as system is online, the Jenkins slave will keep on running and you would be able to check the status from Jenkins Nodes page.

  14. ERROR: Message not found for errorCode: 0xC0000001
    org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000001
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:121)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: jcifs.smb.SmbException: Failed to connect: 0.0.0.0/69.150.30.96
    jcifs.util.transport.TransportException: Connection in error
    jcifs.util.transport.TransportException
    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.util.transport.Transport.connect(Transport.java:154)
    at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

    [2020-02-03 23:40:26] [windows-agents] Connecting to USSTLAMSP22
    ERROR: Message not found for errorCode: 0xC0000001
    org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000001
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:121)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: jcifs.smb.SmbException: Failed to connect: 0.0.0.0/69.150.30.96
    jcifs.util.transport.TransportException
    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

    rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

    [2020-02-04 00:19:26] [windows-agents] Connecting to USSTLAMSP22
    ERROR: Message not found for errorCode: 0xC0000001
    org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000001
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:121)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: jcifs.smb.SmbException: Failed to connect: 0.0.0.0/69.150.30.96
    jcifs.util.transport.TransportException
    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

    rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

    [2020-02-04 00:56:26] [windows-agents] Connecting to USSTLAMSP22
    ERROR: Message not found for errorCode: 0xC0000001
    org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000001
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:121)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: jcifs.smb.SmbException: Failed to connect: 0.0.0.0/69.150.30.96
    jcifs.util.transport.TransportException
    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

    rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:297)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    … 11 more

  15. Hi Ravi-

    Is it possible to assign roles in jenkins on different machines? E.g if i have an application with one DB, 4 app servers and 25 client machines , is it possible to have jenkins install server app on 4 machines and pointing to same DB machine .Also with in clients point to same DB and depending on roles install different stuff on clients. Perhaps like a metadata tag to all the machines belonging to one environment so as in a cloud(like aws) if we spin say two of these environments like above (60 machines), based on metadata tag we can specify which machine belongs to which env.We want to create machine dynamically every single time.

    1. Hi Naren,
      Ideally, You don’t need jenkins to be installed on your APP/DB server, instead you need to connection from Jenkins Slave machine to those servers which is used for the deployment. However if you are talking about Jenkins HA, then you should first consider to go through https://docs.cloudbees.com/docs/cloudbees-core/latest/traditional-install-guide/high-availability & https://jenkins.io/doc/book/architecting-for-scale/ and then decide how many Jenkins masters/slaves server are required.

  16. i have installed slave in my local drive at C:\Users\gaura\jen.

    my jenkins url is : http://34.68.43.235:8080/computer/slave007/
    but my run by connecting to master command which got generated was this :

    <<>>>

    so i changed 35.224.96.117 to 34.68.43.235 then installed the jar and ran the command at local cmd.

    i am sharing error logs below :

    other details
    —————
    root@instance-3:/home/ratav87# ss -tulw
    Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
    udp UNCONN 0 0 *:bootpc *:*
    udp UNCONN 0 0 10.128.0.2:ntp *:*
    udp UNCONN 0 0 127.0.0.1:ntp *:*
    udp UNCONN 0 0 *:ntp *:*
    udp UNCONN 0 0 fe80::4001:aff:fe80:2%eth0:ntp :::*
    udp UNCONN 0 0 ::1:ntp :::*
    udp UNCONN 0 0 :::ntp :::*
    tcp LISTEN 0 128 *:ssh *:*
    tcp LISTEN 0 50 :::http-alt :::*
    tcp LISTEN 0 128 :::ssh :::*
    tcp LISTEN 0 50 :::44349 :::*
    root@instance-3:/home/ratav87#

    ————–

    ip forwarding is off on master server where jenkins is installed .

    —————
    error logs :

    C:\Users\gaura\jen>java -jar agent.jar -jnlpUrl http://34.68.43.235:8080/computer/slave007/slave-agent.jnlp -secret f8347e3bfadaa5396bdc605a91c9781b33497b465a524d5dc49a362b8a7f62e1 -workDir “C:\Users\gaura\jen”
    Apr 20, 2020 12:06:12 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
    INFO: Using C:\Users\gaura\jen\remoting as a remoting work directory
    Apr 20, 2020 12:06:12 AM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
    INFO: Both error and output logs will be printed to C:\Users\gaura\jen\remoting
    Apr 20, 2020 12:06:13 AM hudson.remoting.jnlp.Main createEngine
    INFO: Setting up agent: slave007
    Apr 20, 2020 12:06:13 AM hudson.remoting.jnlp.Main$CuiListener
    INFO: Jenkins agent is running in headless mode.
    Apr 20, 2020 12:06:13 AM hudson.remoting.Engine startEngine
    INFO: Using Remoting version: 4.2
    Apr 20, 2020 12:06:13 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
    INFO: Using C:\Users\gaura\jen\remoting as a remoting work directory
    Apr 20, 2020 12:06:14 AM hudson.remoting.jnlp.Main$CuiListener status
    INFO: Locating server among [http://35.224.96.117:8080/, http://34.68.43.235:8080/%5D
    Apr 20, 2020 12:06:35 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
    INFO: Remoting server accepts the following protocols: [Ping]
    Apr 20, 2020 12:06:40 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver isPortVisible
    WARNING: connect timed out
    Apr 20, 2020 12:06:40 AM hudson.remoting.jnlp.Main$CuiListener error
    SEVERE: Failed to connect to http://35.224.96.117:8080/tcpSlaveAgentListener/: Connection timed out: connect
    java.io.IOException: Failed to connect to http://35.224.96.117:8080/tcpSlaveAgentListener/: Connection timed out: connect
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:217)
    at hudson.remoting.Engine.innerRun(Engine.java:690)
    at hudson.remoting.Engine.run(Engine.java:518)
    Suppressed: java.io.IOException: http://34.68.43.235:8080/ provided port:44349 is not reachable
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:314)
    … 2 more
    Caused by: java.net.ConnectException: Connection timed out: connect
    at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)
    at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
    at java.base/java.net.Socket.connect(Socket.java:591)
    at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
    at java.base/sun.net.www.http.HttpClient.(HttpClient.java:242)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:341)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:362)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1248)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1015)
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:214)
    … 2 more

    1. Hi Gaurav,
      Thanks for the detailed log.

      One suggestion : Never put the actual URL and secret on any forum.

      I hope you are facing an issue while connecting slave to master ?

      It seems the Port is not reachable :

      java.io.IOException: Failed to connect to http://35.224.96.117:8080/tcpSlaveAgentListener/: Connection timed out: connect
      Suppressed: java.io.IOException: http://34.68.43.235:8080/ provided port:44349 is not reachable

      -Are you using any Cloud machine ?
      -Did you verify the Port is open ?
      -Please check the Security Groups and Network Firewall ?
      -Check the port connection on Powershell with : Test-NetConnection {ip/fqdn} -Port {port}

      Once tested, you would be able to find out exact issue and resolve it.

      I would suggest to follow https://devopsbuzz.com/jenkins-windows-slave-configuration-with-screenshots/ which will help you to configure it correctly.

      Hope it helps !!

  17. In need to configure the Jenkins Master & Slave on the same machine.

    Is there ang way to do it?

    Thanks in advance
    Ibrahim

    1. Hi Ibrahim,

      Yes, you can run both master and slave on the same server (just use different home directory for master & slave). However there are many cons compare to pros of using this approach.
      Some pros are :
      – Ideal for learning or Testing one single job
      – Easier to administer only one server
      – If you want to test separate configurations on the same machine

      Cons are :
      – You need use high compute powered server
      – You allow have enough executors defined on the master node to host your jobs.
      – Your master node already provide few executors (based on server config), so having slave on same box, doesn’t make much difference.

      I would still suggest to opt the approach of having separate box for Jenkins master and create several slaves based on the requirements. You can also opt for High Availability by creating clusters for higher region.
      It is easy to manage and jenkins performance will be intact.

      Happy Questing!!

  18. Hi Ravi,

    We have the Jenkins setup on Windows machine which we are using for a existing project. We now have an additional requirement to setup Jenkins for a new project on the same windows server as it will be integrated with the current project after an year or so.

    As per your articles, we can setup slave node on the same server and it should serve our requirement to have Jenkins on same windows server. However, we want to access slave node through separate URL/ports so that there is clear demarcation in accessing Jenkins and their configurations, jobs setups for new project. Also, we need the service to be created on windows for slave node same as master so that it will be a permanent setup.

    Could you please advise on the approach and steps to proceed on the slave configuration ?

    1. Hi Paul,
      Thanks for your comment and glad to know you had setup Jenkins on windows machine without any issue.
      Now, for your requirement – I would suggest to demonstrate the Project teams how their jobs can be configured on same Jenkins instance and only respective team members can access the job. You need to define project matrix permissions and configure users accordingly.

      You can use same Jenkins instance for multiple projects.

      But, if running multiple Jenkins servers on same machine is hardcore requirement – then, you can configure separate Jenkins servers on same windows machine by providing separate ports (JENKINS_PORT=”8080″, JENKINS_PORT=”8081″, etc) You need to check firewall and open the defined ports accordingly. You also need to consider Server configurations in order to create several Jenkins masters/slaves on same machine

      Once you configure separate Jenkins masters – you can configure individual Jenkins slaves on same machine as well.
      That will also provide you different URLs for your Jenkins servers.

      However, I would still recommend to use only one Jenkins server and configure different projects by providing project/job access, which will make your life easy and reduce any performance issue.

      Happy learning !!

  19. Hi Ravi,

    Thank you very much for the response. Requirement is to have separate URL’s to access with separate configurations for projects. As per your suggestion, configuring second Jenkins server by providing separate port(8081) looks promising for us now.
    Could you please help with the steps to configure the second Jenkins server and create service on windows for the second instance ? Also any other things that we need to ensure to avoid issues in the long run.
    Thanks in advance.

    1. Hi Paul,

      You can run two masters on same servers by launching 2 java processes with different connector:
      java -DJENKINS_HOME=/path/to/first_jenkins -jar jenkins.war (this will run on default port 8080 Or change it accordingly)
      java -DJENKINS_HOME=/path/to/second_jenkins -jar jenkins.war –httpPort=8081 (another on defined port 8081)

      Check this link to run multiple slaves (you can use the same approach to configure seperate slaves for your multiple masters) : https://support.cloudbees.com/hc/en-us/articles/217423827-How-to-Install-Several-Windows-Slaves-as-a-Service-

      Worth to read and consider the recommendations as per https://www.jenkins.io/doc/book/architecting-for-scale/

      Happy learning !!

  20. I like the helpful information you provide in your articles.
    I will bookmark your weblog and check again here frequently.
    I’m quite certain I will learn lots of new stuff right here!
    Good luck for the next!

  21. Hi Ravi,

    Thanks for this super article, I have a query on between Jenkins master and slaves network performance issues, is there a way we can monitor ? or do something for better reachability and connectivity ?
    Please do respond I’m waiting.

    Regards,
    Lalit

    1. Hi Lalit,
      Thanks for the feedback.
      It depends on lot of factors, which you can identify and troubleshoot :
      – Is it running on Cloud or On-premises ?
      – Is it clustered (multi master setup) ?
      – Are the servers having enough resources (vCPU, Memory, Disk I/O, etc) ?
      – Are they running behind the firewall ?
      – Are these server dedicated to Jenkins or running other stuff as well ?
      – Do you see network/performance issue all the time or any particular period ?
      – Are you using Jenkins recommended JVM, other settings, such as Java requirement, GC setting, etc
      – Have you configured cache correctly ?
      – Are you keeping the directories clean by removing old logs, data, etc ?
      – Are there any job running on master node (ideally only slaves should run the jobs)?
      – Have you tried using Monitoring Plugins

      Hope by answering above queries, you will get your answers.

  22. Hello Ravi!

    A well written tutorial, a cold beer for you!
    Two observations
    1) There 2 “Mannually” apparitions, should be “Manually”
    2) About “||” for “node1 || master” – and you indicated “And this time you will find the job ran on master build executor since we have given a choice to Jenkins to choose any build executor of master or slave (node1)” – so why was selected the master by Jenkins and not node 1? So, with 2 options how Jenkins does its decision?

    Thanks in advance for the explanation

  23. Hi, I’m trying to activate Jenkins node to host node on mac terminal but getting this kind of error. Please could have any solution?

    Exception in thread “main” java.nio.file.FileSystemException: /remoting: Read-only file system
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
    at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
    at java.base/java.nio.file.Files.createDirectory(Files.java:690)
    at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:797)
    at java.base/java.nio.file.Files.createDirectories(Files.java:783)
    at org.jenkinsci.remoting.engine.WorkDirManager.initializeWorkDir(WorkDirManager.java:211)
    at hudson.remoting.Launcher.run(Launcher.java:321)
    at hudson.remoting.Launcher.main(Launcher.java:297)

    1. Hi Abdullah,

      Thanks for your query.

      It seems you are creating a remoting directory under ‘/’ which is root. Apparently, the root directory on Mac OS is a read-only file system. It is not a Jenkins issue rather its a node configuration issue

      Please provide an absolute path of the directory in MAC for Jenkins nodes. Try creating a test file/directory with the user you configured for Jenkins node and then setup the slave correctly.

      Please let me know in case you face any issue.

      Happy learning !!

Leave a Reply to Mridul Cancel Reply

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top