In our previous articles, we discussed how to Install and Configure Jenkins and how to Configure Jenkins Master-Slave setup on a Linux machine.
I received a few requests to share the approach for Configuring Jenkins Slave on Windows Machine.
So here I am with a new guide on how to Configure a Jenkins Slave on Windows Machine and Install it as a Windows Service.
1- Login to Jenkins and click on Manage Jenkins
2- To create a new Slave – Click on New Node
3- Name the node
4- Fill in all the required details.
Please refer to our master-slave configuration article to know all the details of parameters present on the node configuration page
5- Choose the appropriate Launch method
Below mentioned steps to configure and enable security are essential.
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
7- Then click on Configure Global Security
8- Find out the Enable Security option
9- And then change the
10- Once the new node is created, it will be in Offline mode
11- Now click on the Slave agent
12- You will see Agent is not able to reach the master Jenkins and the new jnlp jar can be downloaded from Jenkins
13- Open the Jenkins URL from Agent Windows Machine and navigate to the Slave Configuration page
Once done, click on Launch Button – You will see a new pop-up that confirms the Jenkins Master-Slave Connection.
Let’s now create and install this as a Windows service to avoid the hassle of going to URL and performing 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 it’s not visible, just maximise the pop-up window
15- Now, click on the Install as a service option
16- It will prompt you for the confirmation
17- Click on OK
18- Go to Windows Settings and then check the Windows Services
19- You can see the Jenkins Windows Slave is successfully configured and running (If not, then Start the Service)
20- Go back to your Jenkins Slave Page, and now you will see that Agent is Successfully Running and ready to build your project
That’s it. You have successfully configured the Jenkins Slave on Windows Machine and installed it as a Windows Service.
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 ?
Thanks.
this guide worked 100% for me, thanks a lot
Thanks Bryan – Glad to know you find it useful.
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
Hi Ravikumar,
Thanks for your query.
As there is very limited information provided, Hope this issue isn’t due to Java version issue https://issues.jenkins-ci.org/plugins/servlet/mobile#issue/JENKINS-27624
Also please refer another support request which was raised by an user who has faced similar issue – https://support.cloudbees.com/hc/en-us/articles/115002626192-Slave-Setup-agent-fails-to-launch
If above doesn’t help then please could you provide detailed master and slave jenkins logs to find out actual error.
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://devopsbuzz.com/jenkins-file-menu-missing/
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
Ravi,
Thanks a lot. It saved me hours of troubleshooting.
Nan
Thanks Nan for sharing your feedback
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.
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 !!
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://devopsbuzz.com/jenkins-file-menu-missing/
Do let me know in case of any issue
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 ?
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://devopsbuzz.com/jenkins-file-menu-missing/
Let me know if you still get any issue
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.
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://devopsbuzz.com/jenkins-file-menu-missing/
please let me know the outcome
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 !!
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.
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.
OK,just disable JNLP-connect and 2 \3,the warning msg gone.
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.
Hi Sakshi,
Thanks for your query.
To sort out this issue, we need more details, such as
– Was this connectivity working earlier or this is the first time setup ?
– Have you checked if JENKINS_TUNNEL is defined ?
– Have you tried to check the connectivity (slave to master server) as described in comment: https://devopsbuzz.com/jenkins-windows-slave-configuration-with-screenshots/#comment-3217
Please try once with above and share detail log in case the issue still persist.
In my case (Linux) Jenkins master is having few slaves as windows and Linux.
1.we are using gitlab for Scm at present and we are moving to git hub
2.Existing Jenkins jobs runs on windows and linux slaves are working fine with gitlab integration and build also successful.
3. when we changes the repo url from git lab to git hub that runs on windows slave node it is giving
“ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo ‘origin’
hudson.plugins.git.GitException: Failed to fetch from repo URL”
but it is working fine for linux slaves.
4.Credential vise same applicable to all jobs(Windows and linux) and provides access to user as well in github.
Any help here is appreciated
Thanks,
Vikas
Hi Vikas,
Did you reset the credentials on Windows slave ?
Run as admin and restart slave
git config –global –unset credential.helper
git config –system –unset credential.helper
Are you able to connect to GitHub repo from Windows slave (check for any proxy, firewall issue) ?
If issue persist, please provide the full stacktrace – hope this helps
Super I have seen for this information how to create windows slave as a service I understand to see this artical super sorcerer keep manage like this thanks once again sir
I had configured and executed job in the Windows Slave node but while I traversed to Workspace and then report directory which was created by angular test , it is giving –
A problem occurred while processing the request.
Logging ID=42e97286-36e5-4880-86a5-f8983e90248b
Hi Vinod,
Please could you provide more details about the issue ?
-> Did you verify the workspace on windows server ?
-> Was the folder created ?
-> What are the errors you are seeing in the Jenkins logs ?
-> Is it happening with any other Job ?
And some other useful details – thanks
Hi,
help pls with below. i am doing on windows.
i have installed slave node.
need help with beloe :
Install python, openssh-server and git on the slave node manually
•Set up the necessary tools such as git, chromedriver(selenium), chromium browser(selenium) on the slave node through Ansible.
Hi Gourav,
Thanks for your comment. Please share the error log which you are facing while installing python, openssh-server, git ,etc
Just for your reference, please see below :
– https://docs.python.org/3/using/windows.html
– https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
– https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
– https://chromedriver.chromium.org/getting-started
– https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html
Hope that helps !!
while launching slave-agent shows error unable to launch application
Hi Hema,
It would be a very wide guess on what exactly causing the issue without the appropriate details.
Please could you share more details about it, such as
– windows/linux?
– same subnet or different?
– firewall checked?
– ports are open?
– security configuration checked?
– any evidence in error message?
– etc, etc
I could not refrain from commenting. Well written!
Pingback: How to launch Windows Slave from Linux Master in JENKINS – Windows Questions
I am having Jenkins master on Linux/CentOS7, and I am trying to setup the Jenkins slave on Windows ( both master and slave are on AWS). I have configured the TCP inboud port fixed 50000 and have created security group to allow inbound access to 50000 port on the slave. I am able to launch the Jenkins dashboard from the Slave machine, and from the node menu when I try to launch the slave it still gives this java.IO.Expection http://xx.xx.xx.xx:8080 provided port 50000 is not reachable
Hi Parag,
It looks like issue with the firewall ports.
Can you please check if the port is open or not on server level
sudo firewall-cmd --list-ports
and if not, then please add it
firewall-cmd --permanent --add-port=50000/tcp
Thank you very much Ravi, this worked for me
Any way to do this without being dependant on JDK on windows slave?
Hi AurimasN
Jenkins runs with a jar file so you need java to run that for you.
What is the exact issue you are facing ?
It’s really a cool and useful piece of information. I am happy that you just shared this useful information with us.
Please stay us up to date like this. Thank you for sharing.
HI Ravi,
I am having Jenkins master on Linux, and I am trying to setup the Jenkins slave on Windows machine and connected successfully. Slave is crated by using .bat file configuration to connect to the master and everything fine.But sometimes slave is went offline with below error:- Can you please suggest on this error behind and solution please.
Connection was broken: java.nio.channels.ClosedChannelException
at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer.onReadClosed(ChannelApplicationLayer.java:238)
at org.jenkinsci.remoting.protocol.ApplicationLayer.onRecvClosed(ApplicationLayer.java:221)
at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(ProtocolStack.java:825)
at org.jenkinsci.remoting.protocol.FilterLayer.onRecvClosed(FilterLayer.java:288)
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.onRecvClosed(SSLEngineFilterLayer.java:179)
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.switchToNoSecure(SSLEngineFilterLayer.java:281)
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processWrite(SSLEngineFilterLayer.java:501)
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processQueuedWrites(SSLEngineFilterLayer.java:246)
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doSend(SSLEngineFilterLayer.java:198)
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doCloseSend(SSLEngineFilterLayer.java:211)
at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.doCloseSend(ProtocolStack.java:793)
at org.jenkinsci.remoting.protocol.ApplicationLayer.doCloseWrite(ApplicationLayer.java:172)
at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer$ByteBufferCommandTransport.closeWrite(ChannelApplicationLayer.java:340)
at hudson.remoting.Channel.close(Channel.java:1501)
at hudson.remoting.Channel.close(Channel.java:1454)
at hudson.slaves.SlaveComputer.closeChannel(SlaveComputer.java:894)
at hudson.slaves.SlaveComputer.access$100(SlaveComputer.java:108)
at hudson.slaves.SlaveComputer$2.run(SlaveComputer.java:774)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Hi Suresh,
Thanks for your query.
Please can you confirm if you have installed windows slave as a service ?
If you are not getting the Jenkins File Menu, then please refer https://devopsbuzz.com/jenkins-file-menu-missing/
Env:
Master jenkins is running with oracle JRE
Slave is running with Open JDK
Problem:
a) javaws is missing from my slave as i am using openJDK
b) whenever i connect via command line i see a-lot of slave Jenkins disconnect becuase of error :
Mar 11, 2022 11:02:27 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 were accepted
at hudson.remoting.Engine.onConnectionRejected(Engine.java:864)
at hudson.remoting.Engine.innerRun(Engine.java:804)
at hudson.remoting.Engine.run(Engine.java:540)
Hi Samyak,
Thanks for your query.
Can you please provide more details about this issue :
– I assume master server is on Linux and slave/agent is on Windows:- Correct ?
– On-premises or Cloud ?
– Is firewall checked?
– Are ports open?
– Is security configuration checked?
– Any issue in master-slave connectivity (check with tcpdump once)?
– Are you using fixed port in Jenkins configuration?
– Is Inbound TCP Agent Protocol enabled for Agent protocols ?
– Were you able to establish the connectivity initially?
– Are you running Slave as a Service or not ?
– Do you see any other error in the slave/master log ?