How to Setup Linux Based Agent Node in Jenkins | Step-by-Step Guide
8K views
Jan 8, 2025
Learn how to set up and configure a Linux-based agent node in Jenkins with this comprehensive guide. Perfect for DevOps engineers looking to scale their CI/CD pipeline. *** 💡 Key Topics: *** 1. Prepare the Agent Machine sudo dnf install java-21-openjdk -y java --version ssh-keygen -t rsa touch ~/.ssh/authorized_keys cat cat ~/.ssh/id_rsa.pub | tee -a ~/.ssh/authorized_keys cat cat id_rsa 2. Add Agent Node and Create Credentials for node * Navigate to "Manage Jenkins" -- "Nodes and Clouds" * Click "New Node" * Enter node name "linux-agent" * Select "Permanent Agent" * Click "Create"
View Video Transcript
0:00
hello everyone welcome back to our
0:02
Channel today we are going to set up a
0:04
Linux based Asen node in genins which
0:07
will help you distribute your build
0:08
loads and run jobs on different
0:11
environments before we begin make sure
0:13
we have a running genkins master server
0:16
a Linux machine for the agent in this
0:18
demo we will be using Rock Linux 9 SS
0:22
access to your agent machine sudo
0:24
privileges on the agent machine all
0:26
right let's get started first step is to
0:29
prepare agent machine in order to
0:31
prepare the agent machine first we must
0:33
install Java so we will be installing
0:36
open
0:37
jdk I have already connected to my agent
0:41
node that is Rock Linux
0:43
9.5 okay now install Java here run the
0:47
command sudo dnf
0:52
install Java hyphen 21 hyphen open
0:58
jdk space hyphen y hit
1:14
enter when zaa is installed verify its
1:17
version andun the
1:19
command Java hyphen ien
1:23
version output confirms that we have
1:25
installed open jdk 21
1:30
all right let me clear the screen now
1:33
next generate the SSS keys for this
1:36
devop user for that run the command
1:40
SSH iph keys
1:44
in iph T and then RSA
1:49
enter
1:53
enter this devops users public key
1:56
stored under this file and private key
1:59
stored
2:00
under this file go to SSH folder cd.
2:11
SSH create authorized uncore Keys file
2:14
here using the touch
2:23
command copy the content of public key
2:27
in this file for that run the command
2:50
view the content of your private key
3:00
we will be using this private key in
3:02
Jenkins UI head back to the Jenkins GUI
3:06
and try to add a note
3:10
there navigate to manage
3:15
genkins click on
3:17
nodes click on new
3:21
node specify the node name
3:27
here select the type as permanent and
3:31
then click on
3:36
create change this number of executor so
3:39
this number of executor is directly
3:41
proportional to your the number of
3:43
course available on your agent node so
3:45
in my case I have two CES on my agent
3:47
noes so I am setting as two so here two
3:50
means two jobs simultaneously can
3:54
execute on my agent
3:56
node remote rout directory so this will
3:59
be my devops users home
4:12
directory labels so label is just the
4:15
name of your agent node so I'm giving it
4:18
as
4:20
Linux in the uses select this use this
4:24
node as much as
4:26
possible under this launch method select
4:29
the second option launch agent bya
4:33
SSH here specify the IP address of your
4:37
agent node go back to your agent CLI
4:41
again type the command host name I
4:45
I copy this IP
4:50
address paste it
4:53
here we need to specify the credentials
4:56
for this host as of now we have not
4:58
configured any credentials so click on
5:01
ADD select
5:03
genkins change that kind as SSH username
5:07
with private
5:09
key ID let's say
5:13
Jenkins
5:15
username is
5:22
devops now go back to your agent CLI
5:26
again copy the content of your private
5:29
key
5:37
click on
5:39
ADD enter here private
5:45
key click on
5:49
ADD select the
5:54
credentials change this host key
5:56
verification strategy select non
5:59
verifying verification
6:01
strategy and leave other parameter as it
6:03
is and click on
6:07
save as you can see one one more agent
6:10
is added in the node section that is
6:13
Linux
6:15
agent can click on this agent go click
6:18
on
6:20
log this output confirms that agent has
6:23
been added successfully and it's
6:25
connected and it's online all right
6:29
now go to the dashboard in order to test
6:32
the functionality of this uh Linux
6:34
agent what we will do we will create a
6:37
freestyle uh project and we will
6:40
schedule that job on this
6:43
agent click on plus new item select
6:47
freestyle project give the name of your
6:50
job as Linux agent
6:53
job click on okay
6:59
choose this option restrict where this
7:02
project can run and specify the label so
7:04
in my case label of my agent node is
7:08
Linux so Linux
7:10
here go to build
7:13
steps select execute cell let's create a
7:19
file using touch command
7:46
click on
7:49
Save now run this job click on build
7:55
now select this job go to the console
7:59
out
7:59
put you will see this job is built
8:03
remotely on this Linux agent whose label
8:06
is Linux under this
8:08
workspace the commands has been executed
8:12
successfully that's all from this video
8:14
tutorial I hope you have found it useful
8:17
and informative feel free to post your
8:19
queries and questions in below comment
8:21
sections do not forget to like subscribe
8:24
and hit the notification Bell for more
8:25
diverse tutorials thank you bye see you
8:28
in the next video