Contents

Configure Windows Jenkins Agent

Configure Jenkins agent in Windows OS

Website Visitors:

Do you want to configure Jenkins as a windows service in your node machine on Jenkins 2.366 or higher version? On this version and above, you cannot install Jenkins as a service directly on agent machine but we got you covered. In this tutorial, we will explain how to configure Jenkins agent in Windows Operating System with Jenkins master version 2.366.

Configuring Jenkins node

Generally, you have different ways to configure Jenkins on agent/node machines as explained below:

  • Login to your agent machine and navigate to your Jenkins URL on your browser. Next, go to the path JenkinsURL/computer/AgentMachineName. Click on Launch option which will start the jenkins-agent.jnlp file download. Run it once the download is complete.

  • Other way is to download the agent.jar file and run it with java -jar agent.jar -jnlpUrl http://master.domain.com:8080/manage/computer/Jenkagent1/jenkins-agent.jnlp -secret c61b -workDir "C:\JenkinsWorkspace" command.

  • Download jenkins-agent.jnlp file from controller and run it on agent using javaws jenkins-agent.jnlp

But from Jenkins version 2.366, when you open the agent URL in your agent machine, it doesn’t show the launch option. So you cannot install it as a service. Because of this, when you download agent.jnlp file and run it in the console, your agent machine will be connected to your controller machine only until that console (from where you run these commands), is open.

If you close that console or logoff from that windows agent machine, it disconnects from the controller server. When you close the console connection between Jenkins master and agent is closed. You can view the same in node log details, it says ERROR: Connection terminated

To solve this problem, login to your Jenkins master and create node as “Launch agent by connecting it to the controller” and save it. Next, click on your node name. When you do it, Jenkins will show a script as shown below. Here, C:\JenkinsWorkspace is the remote root directory. Create a scheduled task in your agent machine using that script. Sample script is shown below:

1
2
3
cd c:\JenkinsWorkspace
curl -sO http://master.domain.com:8080/jnlpJars/agent.jar
java -jar agent.jar -jnlpUrl http://master.domain.com:8080/manage/computer/Jenkagent1/jenkins-agent.jnlp -secret c61b.......... -workDir "C:\JenkinsWorkspace"

Schedule this script to run on windows startup so that the script runs on the agent server continuously after booting up. This way your agent server can have continuous connection with your master server.

So far we’ve explained how you can configure Jenkins agent in contacting the master server continuously. But it is not the end. You can try below steps:

  • You can also run it as a service on your agent machine. Try to configure this script to run as a service in your agent machine.

  • You can also install CYGWIN sshd on your agent server and point master server to use SSH.

Suggested Article

Now that you know about configuring Jenkins windows agent, continue reading our other article Jenkins pipeline here. All other DevOps categories are listed here: DevOps Tools. Have a look at the posts as per your topic of interest.

Conclusion

In this tutorial, we’ve explained how to configure Jenkins agent in Windows OS and its basic usage. We’ve also demonstrated it with examples. We hope you have learned something new in this tutorial.

Let us know which way you’ve used to configure Jenkins Windows agent in the comments section below.

Your inbox needs more DevOps articles.

Subscribe to get our latest content by email.