Setup external JNLP Agents

Created by Tass Skoudros, Modified on Fri, 11 Nov, 2022 at 9:48 AM by Tass Skoudros

Important Note: There is no need to install Jenkins on the agent machine. If you knew that then you know in Jenkins we call these Permanent Agents.

1: On your master machine go to **Manage Jenkins** > **Manage Nodes & Clouds **.

2. New Node: Enter the node name

3. Configure the settings are described in below screenshots. Significance of each field is documented and shown

3. Save and Click on the agent to view connection strings

Make sure you store the secret safe.

if you feel that your secret is compromised, we strongly recommend to delete the agent and create it freshly

Make Sure Points:

  1. Read/Write access to the root directory specified in the agent settings
  2. The agent has internet access and able to reach JNLP URL through the port
  3. Downloaded the latest agent jar from Link available in the agent configuration
  4. Recommended JDK version is 8
  5. We strongly recommend to start JNLP as service, daemon, (or) at-least in nohup (ignore the HUP (hangup) signal)

You will notice below once the connection is established.

Here is a groovy script to create an agent.

import hudson.model.*
import jenkins.model.*
import hudson.slaves.*
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry
 
 
Slave agent = new DumbSlave(
        "MAC-AGENT",
        "/tmp",
        new JNLPLauncher('jnlp-connect-url:50000',''))
agent.nodeDescription = "Agent to run mac builds"
agent.numExecutors = 1
agent.labelString = "mac-agent"
agent.mode = Node.Mode.NORMAL
agent.retentionStrategy = new RetentionStrategy.Always()
 
// Uncomment to add environment variables
//List env = new ArrayList();
// env.add(new Entry("key1","value1"))
// env.add(new Entry("key2","value2"))
// EnvironmentVariablesNodeProperty envPro = new EnvironmentVariablesNodeProperty(env);
 
// agent.getNodeProperties().add(envPro)
 
// Create a "Permanent Agent"
Jenkins.instance.addNode(agent)
 
return "Node has been created successfully."

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article