What is Jenkins | Jenkins Pipeline Tutorial for Beginners | Jenkins Continuous Integration Tutorial
Aug 16, 2023
What is Jenkins | Jenkins Pipeline Tutorial for Beginners | Jenkins Continuous Integration Tutorial
🔥Intellipaat Devops training course: https://intellipaat.com/devops-certif … In this Intellipaat’s Jenkins Pipeline tutorial for beginners you will learn what is Jenkins, how you can do continuous integration using the Jenkins tool and also how to create a CI/CD Pipeline from scratch. 📌 Do subscribe to Intellipaat channel \u0026 get regular updates on videos: https://goo.gl/hhsGWb 📕Read complete devops tutorial here: https://intellipaat.com/blog/tutorial … 💡Know about DevOps certification here: https://intellipaat.com/blog/devops-c … 📔Interested to learn devops still more? Please check similar what is devops blog here: https://intellipaat.com/blog/what-is- … Following are the topics discussed in this Jenkins continuous integration tutorial: 01:13 Why do we need CI? 04:54 What is Continuous Integration? 08:21 What is Jenkins CI? 08:54 Setting up Jenkins 13:50 Jenkins Master Slave Architecture 15:29 Creating Jenkins Master Slave on AWS 26:13 Triggering CI/CD Jobs using Git Webhook Watch complete DevOps tutorial:- https://goo.gl/sTVXfP Interested to know DevOps more? Please check similar DevOps Blogs:- https://goo.gl/U118ds Are you looking for something more? Enroll in our DevOps training \u0026 certification course and become a certified DevOps certified professional (https://goo.gl/iC5gTR ). It is a 32 hrs instructor led DevOps training provided by Intellipaat which is completely aligned with industry standards and certification bodies. If you’ve enjoyed this Jenkins github integration tutorial, Like us and Subscribe to our channel for more similar informative CI Jenkins video. Got any questions about Jenkins basics or Jenkins Installation in windows? Ask us in the comment section below. ---------------------------- Intellipaat Edge 1. 24*7 Life time Access \u0026 Support 2. Flexible Class Schedule 3. Job Assistance 4. Mentors with +14 yrs 5. Industry Oriented Course ware 6. Life time free Course Upgrade ------------------------------ Why should you watch this What is Jenkins video? DevOps is one of the top technologies offering high-paying jobs. Continiuous Integration is an integral part of the Devops Lifecycle. Jenkins is the most widely used tool to implement Continuous Integration. What is included in this What is Jenkins video? You will find that What is Jenkins video has been structured keeping in mind a top-down approach of the topic. Why do we need CI? What is Continuous Integration? What is Jenkins CI? Setting up Jenkins tool Jenkins Master Slave Architecture Creating Jenkins Master Slave on AWS Triggering CI/CD Jobs using Git Webhook Who is eligible to watch this What is Jenkins Video? This What is Jenkins video is both for experienced and freshers who want to move in the Devops domain. #WhatisJenkins #JenkinsPipelineTutorialforBeginners #JenkinsContinuousIntegrationTutorial ------------------------------ For more information: Please write us to [email protected] or call us at: +91-7847955955 Website: https://goo.gl/iC5gTR Facebook: https://www.facebook.com/intellipaato … LinkedIn: https://www.linkedin.com/in/intellipaat/ Twitter: https://twitter.com/Intellipaat
Content
11.57 -> Hello everyone this is Hemant from Intellipaat and I welcome you all to this
15.66 -> session on what is Jenkins. During this
session I'm going to teach you guys
19.77 -> Jenkins from scratch. So let's go ahead
and start with the agenda to understand
24.359 -> what all we'll be covering in today's
session. So we'll start this session by
28.38 -> first understanding why do we need
continuous integration followed by
32.219 -> what is continuous integration.
After that we're going to understand
36.21 -> what is Jenkins and then I'm gonna show
you guys how you can set up Jenkins on
39.84 -> your own computer or on an AWS. So after
that we are going to understand the
44.28 -> Jenkins master slave architecture
followed by creating the Jenkins master
48.42 -> slave on AWS and towards the end we're going
to create a CI CD pipeline which is
53.969 -> going to be triggered by a git web hook.
Alright guys so this is our agenda for
58.53 -> today I hope it's clear to you so
without wasting any more time let's go
61.8 -> ahead and start this session with
the first topic which is why do we need
66.35 -> continuous integration
70 -> so why do we need continuous integration
let's understand this using an example
74.05 -> so imagine yourself being in a company
and where there are three or more
78.13 -> developers who have been asked to add
features to an already existing website
82.41 -> so in the beginning you all were
given version one code and you had to
86.8 -> work on this code to add your features
so developer one had his features to add
90.7 -> developer two had his features to add and
similarly developer three had his
94.33 -> features to add. So developer 1
added his features and he submitted
99.01 -> first and he submitted to the
source code management system and his
103.45 -> code was labeled as version 2 but when
developer two has to submit his work he
108.97 -> basically added changes to the version 1
code not to the version 2 code right so
113.32 -> his changes in the version 1 code had
to be integrated with version 2 code and
118.03 -> only then it would amount to become
version 3 and at the same time you know
124.45 -> testing was also supposed to be done
once this was integrated testing was
128.47 -> also supposed to done to see whether the
new features were been added to the
132.01 -> website. Are they not interfering with
the already existing features of the
136.39 -> website. Is everything functioning normal.
so this was the normal routine or this
141.73 -> was a normal I would say the life cycle
of a software development methodology
146.83 -> so once the bugs have been
identified in manual testing everything
151.06 -> was given back to the developer saying
that you know these are the bugs please
154.06 -> fix them. Now there were problems in this
structure you would say that this seems
159.28 -> perfect but there are some problems in
this structure let's understand those
162.16 -> problems. So the first thing is that
because it took a lot of time and
166.84 -> integrating things and took a lot of
times in manually testing things
172.38 -> developers used to work on three or four
features together and at once say twice
178.15 -> in a six month time or once in a six
month time they used to commit their
182.92 -> changes or to the source code management
system and then a manual integration was
187.45 -> done because such a large code base is
there a manual integration took a lot
191.83 -> of time because there are there were a
lot of features which had to be
195.489 -> integrated and I'm just talking about
three developers imagine a company when
199.599 -> there are 100 plus
developers working in the company right
202.959 -> and everyone is commenting to the source
code management system now integrating
206.41 -> that takes a lot of time and this was a
problem so first you have to integrate
211.209 -> that and of course after that you'll
have to test him and testing was also
214.66 -> done manually which again took a lot of
time and because of a lot of time in
219.489 -> manual integration and manual testing it
affected the time when we will give the
226.18 -> feedback back to the developer now
imagine you submit your work to the
230.17 -> company but you have not got the
feedback how you work is and of course
233.739 -> no person is perfect every code that
goes through the software development
238.33 -> lifecycle will have some bugs that we'll
have to fix right so the developers used
243.19 -> to wait for the bugs to come back from
the testing team and took a lot of time
247.81 -> and this led to a big gap in the
software development life cycle. It took a
252.7 -> lot of time to develop code or to
develop applications with respect to the
257.109 -> features that were requested from the
application and because of this
261.76 -> there was a high risk and uncertainty
when you look at it from the business
265.9 -> perspective because you could not
pinpoint on a date which were near to
269.5 -> the customer expectations it always took
a lot of time to make changes in our
274.03 -> already existing application. So
these were the problems before
278.11 -> continuous integration and we had to
solve this time problem that we have so
282.76 -> that our you know our release cycles
become shorter artwork becomes more
287.68 -> accurate and because of this we came up
with continuous integration so what is
292.69 -> continuous integration exactly. So
continuous integration is basically the
296.38 -> process of having shorter release cycles
by creating small features in our code
303.16 -> and simultaneously integrating them to
our source code management system but
307.96 -> there's a catch the integration and
testing now happens automatically rather
312.76 -> than manually right and this is why
continuous integration is such a hype
317.41 -> it benefits a lot of
organizations because not only do you
322.36 -> have short early cycles that's your
features are going out every day but
326.41 -> also you have automated integrations and
automated testing because of which a lot
331.479 -> of
time gets saved right so how does the
335.18 -> time get saved let me prove you using an
example. So this is a classic scenario of
339.62 -> how things happen these days so you have
a developer the developer finishes his
345.29 -> code and he submits his code to the
version control system which is picked
349.85 -> up by the continuous integration tool.
Now the continuous integration tool
353.42 -> automatically deploys it on the testing
server and the testing server
357.83 -> automatically has built suits which have
been defined for your application it
362.72 -> tests all the features of the
application automatically and if there
366.62 -> are any bugs which are identified
probably a test case failed or something
369.83 -> like that it gives that feedback to the
developer and all this happens in a
374.57 -> matter of minutes, that's how fast
it is now imagine yourself in the
379.55 -> earlier world when I told you it took a
lot of time to manually integrate
383.21 -> things to manually test things so you
used to get feedback in these if not us
388.85 -> and in this case that is today you get
automatic feedback in a matter of
394.55 -> minutes and this has led us to improve
our release cycles in such a way that
400.52 -> today we are getting releases two or
three releases in a day earlier we used
406.73 -> to have releases twice or thrice a year
and now we have two or three releases
411.77 -> every day obviously it's shorter
releases shorter features but that's how
416.57 -> powerful our software development
lifecycle has become with the use of
421.25 -> continuous integration and it does not
stop here. With more mature
425.99 -> continuous integration or with more
mature DevOps model what happens is if
430.58 -> your test succeeds it will automatically
also pushed on to production and
435.86 -> this is the power of continuous
integration
438.77 -> now obviously continuous integration is
just a concept if you want to implement
442.52 -> it, it always will be implemented
using some tools so we're going to
447.35 -> discuss that in a few moments but before
that let us summarize what we just
450.95 -> discussed. So the advantages of
continuous integration include frequent
456.2 -> commits and hence small feature updates
to our website but every day or every
461.41 -> twice or thrice a week.We have
automated built
465.529 -> testing that saves a lot of time. It
gives the feedback instantly to the
470.689 -> developer and also because of this
there's a low risk and faster delivery of
475.339 -> products when you look at it
from the business perspective. Now
479.839 -> like i was saying that all of this is
possible using continuous integration
484.279 -> but continuous integration itself is
just a concept. It can be
489.169 -> implemented using hard code tools and
we're going to discuss that in a few
492.469 -> moments. So continuous integration is a
topic for today and the continuous
497.569 -> integration tool that you're going to
discuss today is Jenkins now Jenkins is
502.129 -> an open-source tool which is basically
used for continuous integration it is
507.109 -> based on Java and a lot of companies are
working on Jenkins to get their
511.399 -> day-to-day work in the DevOps life cycle
done right so this is a brief
516.289 -> introduction about Jenkins and I already
told you the features of continuous
520.519 -> integration or all of them pertain to
what Jenkins can do in your life right
525.709 -> so without wasting any time let's go
ahead and start with Jenkins by first
530.42 -> installing it on your system so how can
you set up Jenkins on your computer now
534.889 -> there are a set of commands that you
would need to run on your Linux box that
539 -> would set up Jenkins but there are two
or three ways you can install Jenkins
542.089 -> with if you have Dokken installed in
your system and you want just into
545.75 -> testing you can have Jenkins installed
in a docker container so with that you
549.98 -> do not have to set up your environment
with Java you do not have to you know go
555.17 -> through the process of downloading
things just download that container and
558.649 -> that would have Jenkins up and running
on your system right but this is a
562.43 -> bare-metal installation that i'm going
to show you guys so let me just switch
565.67 -> back to my server that I that I've
deployed on EWS to see how you can
570.92 -> deploy a server on Jenkins alright guys
so this is how my AWS server looks like
577.61 -> so what I have to do is I have all the
commands written over here in my notepad
581.99 -> so let me copy these commands the first
command will basically install open JDK
586.61 -> 8 on my system so let me do that
okay so it's unable to plate reason as
592.62 -> we haven't updated so let me update the
system first sudo apt-get update
599.1 -> and once that is done I'll install open
JDK
606 -> all right so now it's installing open
dedicated
613.09 -> next step would be to copy this command
this will basically add the Jenkins key
617.5 -> in the repository so let us do that
627.12 -> all right so this is done the next step
would be to install this command all
633.51 -> right
638.07 -> so this is a next one this would
basically add the binary of Jenkins to
644.37 -> this list and now we're going to update
so our
650.18 -> repository links gets updated
655.85 -> and now let's install Jenkins
664.38 -> you
669.22 -> alright guys so Jenkins is installed so
first of all let's check these details
673.72 -> for our Jenkins service so for that we
can check it using service jenkins
679.98 -> status all right so the Jenkins service
is active so our next step would be to
685.42 -> open the port of the ec2 server so let
us do that so the inbound connections
692.67 -> let's open all traffic to be on the
safer side if you want to be more secure
697.69 -> kindly open port
eight zero eight zero because that is
700.93 -> what Jenkins operates on alright and let
me click on save alright so this is done
707.83 -> so now what I'm gonna do is I'm gonna
come back to my dashboard this is my
714.13 -> Jenkins master let me copy the IP
address and this IP address I'm gonna
718.36 -> use with the port ether a zero to open
Jenkins
724.33 -> so you can see the Jenkins dashboard is
now visible so the first time you
730.24 -> install Jenkins you'll have to enter the
administrator password which can be
734.41 -> obtained from this part so what I'm
going to do is I'm going to go to this
738.43 -> part and I'm gonna cat over there so
this will basically
745.13 -> so I let me do a sudo so this would
basically give me the password and let's
750.23 -> copy it and paste it over here
continue
755.83 -> is booting up so the first thing screen
that you would see is customized Jenkins
760.96 -> so let's install this nested plugins
just for basically install all the
764.71 -> plugins that we would require for
today's session
769.33 -> so once you've clicked over there your
plugins will start to install and we are
774.279 -> wait a while until this finishes
779.55 -> all right a next screen is going to add
a oscar for adding a user so let us do
785.04 -> that let's give the user name as in
telepath password as inter a part
794.12 -> when you filled out all the details
let's click on save and finish and this
800.449 -> would bring you to your Jenkins
dashboard so you would get the Jenkins
804.259 -> is ready page and just click on start
using Jenkins
808.17 -> all right so this is how your Jenkins
dashboard looks like and we're gonna
812.31 -> come back to this but before that let's
just go back to our slides all right so
817.98 -> guys we've installed successfully
installed Jenkins on our system our next
821.94 -> topic would be to understand the Jenkins
master slave architecture all right how
827.34 -> does Jenkins work in the production in
mind is what we are going to discuss
831.42 -> over here so the tank is master slave
architecture is basically important
835.77 -> drink complex continuous integration
reason being your testing will always
840.66 -> happen on the testing server and your
production code will always be deployed
844.98 -> on the production server right you
always have to deal with multiple
847.92 -> machines when you're working in a DevOps
environment and that is exactly why you
853.41 -> need to Jenkins master slaves so for in
this kind of situation where you have to
857.34 -> deploy your code to the testing server
Jenkins becomes your master perso and
863.55 -> your testing server becomes useless
server for Jenkins right similarly your
868.47 -> production server would become slaves or
for Jenkins and the master Jenkins will
873.63 -> only have the Jenkin installation
Jenkins will not have to be installed on
878.7 -> any of the other systems which are
serving as the slave of Jenkins right
884.13 -> the third thing is why do we need a
master slave kind of scenario so I've
890.07 -> seen a lot of people basically just use
Jenkins on the same computer where they
895.29 -> have to deploy the code as well and that
is because they are not dealing with
900.11 -> probably parallel jobs of deployment or
they are not dealing with complex bills
905.97 -> and that the reason they have it on the
same machine but when you are working on
909.45 -> to the production environment you have
to have a master slave kind of an
914.52 -> architecture where in the testing and
the production server would become slave
917.88 -> for your Jenkins master all right so now
what we're going to do is we over a set
922.74 -> up master slave on AWS and let's see how
we can do that all right so the first
928.14 -> thing that we have to do is deploy two
servers on AWS that is slave one and
932.61 -> Slade two and then we connected to
Jenkins using the jnlp can I
936.829 -> so let's see how we can do that so the
first thing that I'm going to do is let
940.369 -> me jump on to my easy to my admin
console and let me create two slaves
954.49 -> you
961.33 -> by specifying the number over here that
is too
967.43 -> so we're going to launch the instances
so our instances are launched let us
974.33 -> rename them as slave 1
984.32 -> and we have our other witches slave do
now mind you guys we will not be
991.23 -> installing Jenkins on either slave 1 or
slave 2 we will be controlling these
995.94 -> slaves through the Jenkins master now
there are some settings that you will
999.69 -> have to do in your Jenkins master let us
go through that so the first thing so
1003.68 -> this is your dashboard so the first
thing that you have to do is you'll have
1007.13 -> to go to click on Jenkins and go to
manage Jenkins go to configure global
1011.63 -> security
once you are here just scroll down and
1016.079 -> you will reach this section which talks
about agents now over here we are
1022.019 -> talking about TCP port for genies be
agents just change this to random and
1026.549 -> click on save
1030.57 -> once you've clicked on saves now we will
go to manage nodes and now we will add a
1036.6 -> new node let's name this node node as
slave 1 and now click on permanent agent
1044.16 -> and click on ok.now over here you will
have to add
1050.51 -> the launch method will have to change it
to launch agent via Java Web Start and
1058.21 -> the current working directory path
specify that to slash home slash window
1064.7 -> and slash Jenkins alright just specify
this and click on save you will reach
1072.35 -> this screen so I'll tell you what to do
after this
1075.44 -> for now let's add one more new node
let's name it as slave two and we'll
1084.409 -> copy everything from slave 1 and click
on OK
1092.21 -> all right so everything is the same so
the remote root directory would be this
1098.36 -> slash home slash mundo and then Jenkins
1105.01 -> all right so slave 2 is also configured
let us check what we can do now all
1111.82 -> right so the next thing that you have to
do is now click on slave 1 and download
1117.07 -> the agent jar by clicking over here
alright so your agent or jar is now
1122.559 -> normally I had one before so just ignore
this thing so this agent dot jar is now
1127.69 -> downloading and now I'll have to send
this file to my slave and so and I'll
1134.95 -> show you how you can do that right for
now just click on show in folder remove
1140.62 -> the older agent rename this as
agent
1148.09 -> all right and now we'll have to send
this to our slave 1 and the way we can
1154.09 -> do that is by first selecting slave 1
take the IP address from over here we'll
1160.33 -> have to download a clock client called
FileZilla just open that in FileZilla
1165.7 -> paste the IP address over here use name
would be Ubuntu for the window operating
1171.13 -> system port is 22 and in the settings
you'll have to click on edit and then
1176.8 -> click on settings go to SFTP and you'll
have to add the key file over here viral
1183.22 -> already added that just click on add key
file just go to your key file select
1188.02 -> that click on open and you be added over
here this is important to connect
1191.95 -> because when you're connecting to EWS
the only method that you can connect to
1195.49 -> is using your PEM file or your PPA file
and this is the way you can add it in in
1200.44 -> your files at our browser right so once
you have added that just click on quick
1206.05 -> connect and now you will be connecting
to your slave 1
1212.68 -> so once you are connected you will be
given all the directory so here are all
1217.33 -> the directories now I'll have to copy my
agent Gaad jar on my slave once just
1226.45 -> click here and it will copy your file to
slave 1 ok so let us also verify that if
1236.83 -> our slave 1 has been copied or not so
let us connect to our slave 1 so we'll
1241.45 -> connect it using this IP address let us
go to put the click on your session
1247.2 -> connect to slave 1
1252.61 -> and let us give a special appearance to
this let us give
1261.58 -> let us decide a color on this let us
decide the orange color so the orange
1266.47 -> color is slave 1 so let's click on OK
and let's click on open
1273.31 -> all right so login as Ubuntu
1278.27 -> great so now if I do an LS I can see
that agent or jar has been successfully
1284.179 -> copied all right so slave 1 is done now
we'll have to do the same thing for
1290.09 -> slave too so let us go to slave to
download the agent or char
1297.549 -> while it's downloading just copy the IP
address for slave 2
1304 -> enter it in FileZilla so that we can
connect to it
1314.409 -> all right click on quick connect
1322.81 -> so you will have the directory listed
over here
1328.12 -> all right now we'll go here and we'll
rename our agent one dot jar
1336.809 -> two E's in Georgia and the way we can do
that is like this so we'll just go here
1345.35 -> rename this
1353.38 -> all right remove the water reading file
and I'll rename this to agent or job
1361.279 -> once that is done just drag and drop it
on the sole
1367.86 -> and now let's connect the slave to using
pootie
1372.91 -> so let's click on your session
1376.97 -> as such add the file
1383.69 -> and let us keep the color for this slave
as white say all right
1390.81 -> so this is slave to
1396.82 -> I do an LS over you
1400.38 -> it's the Agent Orange our file has been
copied successfully
1405.59 -> all right so now the next step would be
to basically go to your slave
1412.78 -> and you'll have to execute this
particular command at the place where
1418.24 -> your agent jar is present all right but
before executing this command will have
1422.83 -> to install open JDK on both these swords
that is slave to and slave one so let us
1428.14 -> do that
so here is the open JDK command let us
1431.74 -> pass it over here
so we'll have to update the server first
1436.16 -> let us update it
1444.05 -> you
1448.559 -> all right and
is the command right so while Java is
1455.039 -> being installed over here let's do the
same for us slave 1 as well so let's
1460.38 -> update it first
1468.54 -> you
1474.7 -> so it's updated and now let's install
JDK
1482.48 -> all right so while Java is being
installed on this I think we are almost
1487.58 -> done on our slave - all right so slave
to the jar the Java is installed so what
1498.77 -> I can do now is I can go to my champions
page and go to slave 2 and I can run
1509.48 -> this command over there now and this is
it the moment you run this command
1519.36 -> can you see it says connected and the
moment it says connected just come back
1524.129 -> here refresh the page and your slave 2
is now connected let's do the same with
1529.35 -> our slave 1 just copy this command
1535.91 -> go to your sleep one clear the screen
and basis command
1543.78 -> all right so
both sleeves are connected to your AWS
1549.5 -> Jenkins solo and your set so if you see
the nodes you have a master now you have
1555.36 -> slave 1 and you have slave 2 and this is
what we were supposed to do so let me
1561.48 -> come back to my slides all right so we
have successfully setup Jenkins master
1567.33 -> slave on AWS our next task is to
basically create a pipeline which would
1573.269 -> be triggered by get webhook to deploy a
project on Jenkins let us do that so for
1578.58 -> that these are the steps that we'll have
to do so basically we have a project
1582.6 -> I've created a project on my github
repository now this project has a doc
1587.429 -> file and this docker file can be built
to basically deploy a website on docker
1593.25 -> all right so we're going to deploy a web
site on our slave one first which will
1598.59 -> basically act as our testing server it
will be sudo testing kind of a thing
1602.25 -> right and if our website is successfully
deployed on us s server that is slave 1
1609.299 -> it'll then be get deployed on slave 2
which will be our production server so
1614.88 -> this is basically a job and this should
happen automatically so up get web boo
1620.58 -> basically means that the moment I commit
on git it should automatically trigger
1625.85 -> job on Jenkins it should automatically
deploy the website on my website on my
1633.57 -> testing server first if it gets deployed
successfully then it should move forward
1637.95 -> and deploy the same on my production
server alright so this is what we are
1642.09 -> going to do so let us quickly go to our
github website to see how our code looks
1649.71 -> like so basically this is my code guys I
have the docker file I have the website
1654.659 -> in here docker compose please ignore it
we are not going to use it so we're
1658.769 -> going to use the docker file the docker
file code looks something like this so
1662.73 -> basically this is a container which it's
going to pull and after pulling the
1666.419 -> container it is going to add the DevOps
IQ folder inside the where W W HTML
1672.24 -> DevOps IQ directory that is this is
inside the container all right so this
1676.5 -> is getting now this will get deployed
inside
1679.41 -> my sir would once I trigger it from
Jenkins now to do this first we have to
1687.08 -> install Jenkins on both the slaves as it
is mentioned in the steps and like it
1693.15 -> says like we will have to configure it
in a way that if the build on Jenkins
1697.68 -> slave 1 is successful then it should be
built on slave too once it's done we
1702.63 -> should finally trigger the job using
gate prep box
1705.51 -> all right so let's do this guys let's go
ahead and start with the demo so that
1709.83 -> let's see how it can be done all right
so the first thing that we are going to
1713.46 -> do is install docker on both the slaves
so let us go to put eternal let's go to
1719.4 -> slave 1 first now remember guys you will
have the connected state over here do
1724.41 -> not close this terminal otherwise your
connection will stop so what I'll do is
1730.02 -> I'll just minimize it and I'll duplicate
the session so that I can work in a
1733.86 -> different terminal
all right so the first thing that we
1737.51 -> have to do is install docker so let's do
that
1739.82 -> sudo apt-get install docker dot IO ok
so
1748.84 -> installing now so Wild Orchid installing
over here let us do the same on slave to
1754.27 -> so just duplicate the session
1758.85 -> and go to Punto
1763.81 -> now install dog
1771.52 -> you
all right so doc docker is being
1775.41 -> installed on slave - it has installed a
slave one let us check so docker - I
1783.51 -> have inversion if we can do that that
means docker is installed yes
1787.68 -> docker is installed on sleep one
and is installed on slave to as well
1795.12 -> let's check the sudo apt pseudo docker
version
1803.26 -> okay so docker is installed on slave two
ways well awesome
1807.34 -> so our first job is done we had to
install docker now our next job is to
1813.94 -> configure Jenkins to build the project
on slave one if successful should be
1817.419 -> built on slave too so for this we will
have to go to Jenkins
1823.5 -> so Jenkins is over here and we'll have
to create a job all right now you can
1828.21 -> check the status of your slaves over
here so you can see that master is idle
1832.35 -> slave is also idle and slave to is also
idle now first let's create a job for
1837.419 -> our slave 1 so our slave 1 basically
will have a pre side project and let us
1842.309 -> name slave ones job as slave 1 so let's
name it as test ok and then click on ok
1854.179 -> all right so the job has been created
now the first thing that we had to do
1858.39 -> was to copy our code to the workspace so
let's uh scope clone a repository or it
1865.11 -> mentioned the repository link over here
and by clicking it up project ok and
1870.48 -> then go to source code manling click on
kit and mention your repository over
1874.35 -> here as well now because this job has to
run on slave 1 we'll have to just shit
1878.97 -> where this project can be run and select
slave 1 right so slave - job and loosely
1888.51 -> one once you select slave on this job
will only run on slave 1 ok once you
1894.27 -> have done with that the next thing that
you would have to do is come down and
1899.159 -> click on add build step but before doing
this let us check if you know my job is
1904.71 -> being built or my workspace is being
populated by the git repository content
1909.659 -> if I build this job on sleep one right
so this would basically test our
1913.74 -> connection as well so let us do that so
let me click on build now and this will
1918.75 -> basically start a build wherein it will
copy the get content on slave 1 ideally
1925.38 -> right so the blue ball basically tells
us that the job has completed
1930.21 -> successfully so let us click over here
and I can see that you know it has been
1934.98 -> successfully being finished
so let us verify that let's go to slave
1938.97 -> 1 and if I do an LS over here great so I
can see the workspace is there let me go
1944.1 -> inside workspace
1947.58 -> all right so inside workspace let us see
what do we have we have test so this is
1952.499 -> the job name awesome so if you go inside
test do we have the git repositories
1956.759 -> content yes we do
alright so my git repository was
1959.789 -> successfully cloned into the test shop
that basically means from my master I'm
1965.039 -> able to build a job on the slave one
node which is great so that basically
1970.799 -> means our connection is working fine
awesome so let's go ahead and go back to
1976.08 -> configuring our job right so what we
want to do is we want to deploy the
1981.269 -> website which is mentioned over here in
this repository to my project now the
1988.409 -> way to do that is by running this docker
file right for running this docker file
1993.21 -> I'll have to check what is the present
working directory so my present working
1996.96 -> directory is this so let us copy this
and once you come back to Jenkins you'll
2001.97 -> have to scroll down and click on add
build step once you click on add we'll
2006.2 -> step click on execute shell what will
execute shall do so execute shell is
2011.389 -> basically used to run any commands that
you want to run on the terminal of the
2016.309 -> other machine that you're trying to
build on Jenkins right for example we
2020.359 -> are trying to build on slave one from
Jenkins so what commands do we want to
2024.259 -> run over there so I want to run docker
build command so it's a docker
2030.98 -> build and then hive dockable and then
the repository where the dockerfile is
2037.399 -> so it's over here and then the name of
the image that I want to give so the
2042.23 -> name of the image would be say I want to
say it's test okay so this is the image
2049.339 -> name once the image is built I'll have
to run it so let's run it on port 80 no
2055.549 -> so let's land on port 80 - and then
let's
2063.33 -> means like this so this is the command
for running the docker image that you
2067.05 -> have just built right once it's built
the next step would be to check whether
2074.49 -> it's there or not we can do that on the
browser and I forgot one thing
2078.24 -> I'll have to add pseudo and because this
job can be build time and again what
2084.33 -> we'll have to do is we'll have to remove
the older containers which are running
2088.17 -> on the system right so for doing that I
can say that sudo talker
2095.61 -> RM - F and for removing all the
containers which are running I'll have
2101.44 -> to pass in sudo docker PS - a and - Q
this should delete all the containers
2111.16 -> which are running inside my sleeper now
to check if my docker file is building
2116.56 -> my containers or not what we can do is
we can simply copy the commands from
2122.92 -> over here so the first thing that I want
to do is I want to build it let's build
2127.89 -> medaka file
so the file is now being built
2138.9 -> awesome so it's been built the next
thing that I want to do is I want to
2143.76 -> check if I want to run this command
right so for running it the command is
2149.549 -> this let's copy it paste it over here
hit enter and my container is now
2155.67 -> running so I'll have to check that if
it's running or not so I go to slave 1
2161.92 -> papi this
paste it over here so and port number is
2168.89 -> 82
2171.74 -> so I can see the Apache base that means
the container is working let's check if
2176.57 -> our files are being showed or not so if
I go to develop psyche folder yes I can
2182.51 -> see the website so means these commands
are running fine but what I have to do
2187.67 -> is I have to check if it's running
through docker or not so I have
2191.27 -> configured the commands over here and
these commands are work on the terminal
2194.9 -> they should work over here as well right
so let us go ahead and save this
2201.83 -> okay so our job has been saved and the
next thing that I would do is let me
2207.61 -> remove all the containers which are
running over here so for that I have to
2214.52 -> do Rock of PS
2218.26 -> let me remove this container
2226.45 -> so the container is removed now let's go
ahead and run this container run this
2232.85 -> job
2237.67 -> all right so now let's go ahead to our
Jenkins dashboard and let's build the
2243.819 -> project now to see if everything goes
fine so I've clicked on build now
2250.64 -> all right so it gives me a field bill
let's see what the problem is so the
2255.71 -> problem is
over here it says the first command sudo
2261.67 -> docker PS - da - cue blocker I am
require at least one argument okay so
2268.93 -> I've got the problem so the problem is
there is no container running over here
2272.65 -> as of now right and that's why it is not
able to remove any container and that's
2276.73 -> why this is it is giving me this error
okay to swallow this what we can do is
2281.56 -> for now let's
in the configure part let us remove this
2288.86 -> line or what we can do is we can start a
container over there right so let's run
2293.76 -> any arbitrary container docker run - 90
- D and then we'll do let's run it so
2303.15 -> that there is a container running
because ideally there will be one
2307.68 -> container running at least on my
system so let's click on save
2316.61 -> try to build the project
2321.83 -> okay so the build has gone successful
okay fourth checking that I'd say let's
2328.25 -> just refresh this and yes my website is
being deployed over here
2337.55 -> so let me just do it one more time so
I'm sure it's working
2342.109 -> so let me just do a dr. PS
2351.72 -> you
sudo Locker PS and let's move this
2357.96 -> pseudo doctor
2361.97 -> RM F&F remove this and now let's run our
arbitrary continued
2373.8 -> let's ensure that this website is now
not working
2378.91 -> so it's not working now let's rebuild
this project
2388.41 -> all right so now if i come here and i
refresh this yes so the website is
2393.39 -> working successfully awesome
so it's works on slave 1 let us now
2397.65 -> configure the same thing in slave to
west belle right so let's come back to
2401.94 -> our dashboard so the test job this could
be our arbitrary test shop so basically
2407.94 -> we are trying to deploy it on a server
if it gets deployed successfully we are
2412.41 -> going to deploy it on the Proud as well
so let's create a new job and let's name
2417.21 -> it as prod
free start project click OK and the
2424.079 -> github project is going to be the same
this one
2429.91 -> let's place the URL over here and we
have to restrict this to run on slave 2
2441.539 -> great the source code management
diskette repository
2452.38 -> and the build step also would be the
same so basically we want to delete all
2460.269 -> the containers which are running right
now so for that it's sudo docker RM
2465.39 -> hyphen F dollar docker PS - 8 and I
think you okay next step is to build a
2475.359 -> file to do sudo docker run - 90 - P and
we want to run it on port 80 because its
2486.339 -> production right and the
image name is dest
2495.299 -> - D and - and before this you forgot one
command which is pseudo docker build
2503.44 -> and then the directory which is flash
home / bun - slash workspace / the job
2513.94 -> name which is broad
and then over here it did aqua fire
2520.69 -> would be pleasant and I want to name it
as sea
2529.03 -> production the container name would be
production and over here also the
2534.47 -> container name would be production
awesome so let's click on save
2542.36 -> and let's now try to build it but before
that we'll have to launch one container
2547.7 -> on test so let's run an arbitrary
container
2557.93 -> you
2561.5 -> all right
so container is ready now let's check by
2568.85 -> clicking on bell now if this job is
working fine
2575.54 -> so we have clicked on built now and if
you want to see the console output we
2579.68 -> can see it over here
2585.839 -> okay so it says job failed and the
reason for that is god permission denied
2593.789 -> okay so the problem is I have forgot to
add pseudo so let's add pseudo
2600.39 -> let's add food over here and that should
be it let's click on save and let's try
2606.99 -> it again
2612.21 -> okay again they have a problem but I
think it's new error so let us try to
2618.119 -> resolve that so it's unable to prepare
context and the path is slash home slash
2622.829 -> you're going to workspace and fraud not
phone okay so let's check if this path
2627.93 -> exists so we if you do an LS we have
Jenkins okay let's go inside Jenkins if
2633.96 -> you do an address
okay so workspace is over here so
2637.23 -> basically I'll have to change the path
to
2644.15 -> slash home slash a bun to slash Jenkins
slash box
2652.65 -> Brod - t and then production you can
save if we check if there is a container
2658.95 -> running on my slave -
2665.05 -> if there is no container running the lab
to run macho pseudo
2674.19 -> run - 90 - d12 ok container is running
and that is also ensure that we do not
2683.25 -> have any website running on mad
2686.94 -> slave to
2690.1 -> okay so this is the command if you are
getting ready this is the hope with the
2693.4 -> do getting right now all right so let's
click on bill now and let's see if I
2697.27 -> build a successful
2702.23 -> all right so it's getting built let's
hope for the best
2706.01 -> let's hope it successful
all right so it gives us a blue sign
2709.89 -> blue means that build was successful
let's try to refresh over here
2714.779 -> and yes it works now let's just go to
DevOps iq folder and see if our website
2720.959 -> is up and running yes so our website is
up and running awesome guys now what I
2726.689 -> want to do is I want to trigger so first
I want to trigger prod job only when the
2731.759 -> test job is completed now let's see how
we can do that so we'll go to configure
2738.319 -> and let's see if we can configure this
all right so I'll have to go to - of
2746.4 -> actually let's go to the test shop let's
go to configure and over here I'll have
2754.679 -> to go to add post build actions
ok let's click on that and after this
2760.049 -> we'll have we'll say build other
projects click on that and which project
2765.719 -> to build I want to build prod
2769.71 -> and trigger it only if the bailiffs
table so if the bill passes only then it
2777.9 -> should start with prod okay awesome
great so let's click on save
2790.18 -> and if my test
gets succeeded then my
2796.41 -> fraud job will run alright so let us
check this as well so let me try running
2803.97 -> it so we can run the test job using the
pipeline view as well so if we you just
2810.509 -> have to come back to the dashboard and
over here you will find both your jobs
2813.72 -> just click on the plus sign that you see
you over here and once you click on the
2818.279 -> plus sign you should be seeing a build
pipeline view option over here if you
2823.95 -> are not so that means the plug-in is not
installed so let's install that plug-in
2827.579 -> for that you have to click here go to
manage Jenkins and then click on manage
2832.44 -> plugins click on available and then
search for build pipeline
2841.6 -> build pipeline select it and then
install without restart just click on
2850.96 -> that
2853.72 -> all right and now Europe your plugin
will start to install on your Jenkins so
2864.18 -> all right so my bill pipeline plug-in is
installed let us go back
2870.32 -> dashboard click on the plus sign and you
can see there's an option down which
2874.49 -> says build pipeline you select that and
name this viewers CI CD or anything that
2880.67 -> you wanted right
click on OK
2885.47 -> all right
2889.43 -> everything seems fine over here bill
pipeline new title let's name it as CI
2895.41 -> CD ok let's click on
2902.46 -> okay
2908.92 -> you
2917.78 -> all right let's check so in my CI CD
view I just see the broad job so let's
2924.2 -> see how we can fix that so I want the
test job to also be there so let's see
2930.85 -> so let's click on configure
2937.1 -> and build other projects after the test
is done okay
2949.029 -> you
2963.63 -> okay so we forgot to choose the initial
job
2966.839 -> so the initial job will be test right
and let's click on okay
2972.72 -> okay so now it looks good so the first
the test job will be executed and then
2979.65 -> we'll have the broad job executing
2989.75 -> okay let's try running these jobs by
clicking on run
2999.51 -> you
3017.68 -> all right so as you can see our test
shop started and then our prop started
3022.24 -> and it completed so this completed in
1.5 seconds and this completed in 1.5
3027.43 -> seconds as well and both of these have
these websites awesome now what I want
3034.69 -> to do is I want the moment I commit on
my github this should trigger my Jenkins
3042.25 -> job so for doing that let's go over here
that is my Jenkins dashboard and let's
3051.67 -> try doing that
with tests okay so we'll click on tests
3057.83 -> and we'll click on configure
all right and
3071.72 -> you
yes so in the bill triggers option just
3076.16 -> go to github hook trigger forget SEM
polling alright and just click on save
3084.79 -> the moment that's done just come back
here on your github so for configuring
3091.04 -> your web book all you have to do is
click on settings and click on settings
3095.81 -> go to web hooks inside my books click on
add web hook and now just copy the IP
3102.2 -> address and port number of your Jenkins
dashboard or your Jenkins page and paste
3109.46 -> it over here slash github
3113.99 -> - the book specify that and click on add
book
3122.39 -> if the response is received by gate and
everything works fine it will give you a
3126.5 -> tick which means everything is working
fine right and just go back to your
3132.38 -> dashboard and you can see that
everything works out great now what we
3138.59 -> have to do now is we have to push a
commit on github and that should
3143.51 -> automatically trigger a build over here
so let us check that so we'll just open
3148.94 -> this over here and we'll go on
3155.14 -> Master let us trigger a build so this
build can be triggered from anywhere I'm
3160.43 -> just doing it on master for the sake of
simplicity so I'll just do a get load of
3165.31 -> your repository
3172.76 -> get clone
all right everything is
3177.55 -> now I have something on my
3185.47 -> I have a website right so what I'll do
is I'll change the contents of that
3189.43 -> website let's see if that content is
visible on a service as well so I'll
3197.17 -> just change the index file
3201.48 -> I'm gonna change is the title so I'll
change this as Jenkins prod website okay
3208.71 -> and let us change the image as well so I
have one more image over there so let's
3213.18 -> name the images to jpg
great so now let's push this on docker
3220.21 -> hub so let's add it commit it
3226.31 -> all right and let's push it now
3231.08 -> get push origin master the username and
the password all right so the push has
3238.25 -> been made let's check if anything has
triggered over here
3244.49 -> so as you can see the test got triggered
and now the prod also got triggered so
3249.2 -> both the jobs have been successfully
completed just wanna push let's verify
3253.099 -> that so this is my
3258.1 -> so
let me see which one is my slave one so
3264.349 -> slave one is 1:08 she let us see okay so
this is my slave one let us refresh this
3271.429 -> and see which website is coming as you
can see the background board changed and
3275.269 -> as well as the
title also got changed similarly if this
3280.65 -> job is successful it should also be
triggered over here let us check if the
3284.76 -> website is also pushed here and yes so
job is also pushed here
3289.26 -> awesome so let us try this one more time
and with this let us try to bring back
3297.15 -> the same
3301.8 -> background that we had right so let's do
a nano on index.html
3308.61 -> and let's change the title to Jenkins
final website
3316.65 -> and let's change the image name to one
dot jpg which was the earlier image save
3324.539 -> it
now let's push it on github so we'll add
3327.9 -> it
committed
3335 -> and now let's push it
3342.06 -> all right so our code is now being
pushed it's been pushed now let's come
3347.26 -> here and see what is happening so our
job should now be running so test got
3354.1 -> completed fraud is being completed
3359.01 -> so prod is running right now
and prod also got completed successfully
3365.119 -> awesome so let's check if a website got
changed over here so this is my testing
3369.74 -> server so the title got changed and even
the background let's see for a
3375.11 -> production and even a production website
code changed so awesome guys we have
3380.18 -> successfully completed what was asked to
us in the hands-on so we were supposed
3385.49 -> to create a Jenkins pipeline which would
basically if slave one job is completed
3391.67 -> should be built on slave 2 and the job
should be triggered by a gateway book
3396.619 -> and that we have done successfully
alright guys so I think we are done so
3402.02 -> thank you guys for attending today's
session I hope you guys learned
3405.17 -> something new today so if you've got any
doubt that you have that you're doing
3409.61 -> this session or if you've got any errors
while doing the same demo as I was doing
3413.48 -> you can push it down in the comment
section we'll be happy to answer it for
3416.6 -> you alright so thank you guys for
attending today's session I hope you
3420.95 -> have learned something new today so see
you again in the next session good bye
3425.3 -> and have a great day
Source: https://www.youtube.com/watch?v=QCXtNrIVdcw