How to create an agent in Linux from console

Issue

How to create an agent in Linux from console

Environment

Resolution

For adding a node as an agent to Jenkins master using the console, follow following steps.

Step 1: On Jenkins master go to Manage Jenkins > Manage Nodes.

New node link

Step 2: Select New Node and enter node name.

Step 3: select Permanent Agent -> Press OK.

Node name

Step 4: On the next page, fill in the following fields:

Set a number of executors (one or more) as needed. Default is 1.

Set a Remote FS Root, a home directory for the master on the agent machine. i.e ???/opt/jenkins/???

Set Usage to ???Use this node as much as possible???.

Choose Launch method as ???Launch agent via Java Web Start???.

Set Availability, ???> Keep this slave online as much as possible.

Press Save.

Configure job for slave

Step 5: Now for connecting to agent to the master by

Open a browser on the agent machine and go to the Jenkins master server url (http://YourJenkinsMaster:8080).

Go to Manage Jenkins > Manage Nodes, click on the newly created agent machine.

Run from agent command line. Login to agent node -> download the slave.jar file from Jenkins Master UI to agent machine then while executing the command, please specify download path of slave.jar file.

Agent not connected
On your console:

nohup java -jar /opt/jenkins/slave.jar -jnlpUrl http://YourJenkinsMaster:8080/computer/NameOfYourSlave/slave-agent.jnlp -jnlpCredentials userJenkinsMaster:passwordJenkinsMaster &

Now agent node will be in Connected state.

Agent connected

We recommend you choose connecting agent with ssh in linux servers How to connect to remote SSH Slaves because of this advantage:
* If you restart your jenkins instance with any agent connected by JNLP you’’ll lose the connection with your agents but if you use ssh Jenkins manages the connection with the agents so if you restart Jenkins all the agents should remain in place.

References

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.