Jenkins Tutorial for Beginners | Jenkins Tutorial | Intellipaat

Jenkins Tutorial for Beginners | Jenkins Tutorial | Intellipaat


hello everyone welcome to this session
on Jenkins. During this session, I’m gonna tell you guys why do we need continuous
integration and then move on to understand what is continuous
integration exactly. After that I’m going to show you guys what is Jenkins and
then discuss how we can set up Jenkins on your computer. After that I’m going to
explain you guys the master/slave architecture of Jenkins and then we’ll
see how we can install the Jenkins master slave on AWS. Finally, I’ll show
you guys how you can create a CI/CD pipeline using Jenkins which will be
triggered using a Git Webhook alright. So, without wasting any time guys let’s
get started with our session with the first topic which is why do we need
continuous integration. Alright so why do we need continuous integration let’s
understand this using an example. So imagine yourself being in a company and
where there are three or more developers who’ve been asked to add features to an
already existing website right. So in the beginning you all were given version 1
code and you had to work on this code to add your features, so developer 1 had
his features to add, developer 2 had his features to add and similarly developer
3 and his features to add right. So developer 1 add added his features and
he submitted first right and he submitted to the source code management
system and his code was labeled as version 2. But when whether but to has to
submit his work he basically added changes to the version 1 code not to the
version 2 code right so his changes in the version 1 code had to be integrated
with version 2 code and only then it would amount to become version 3. And at
the same time you know testing was also supposed to be done once this was
integrated testing was also supposed to done to see whether the new features
have been added to the website, are they not interfering with the
already existing features of the website is everything functioning normal. So this
was the normal routine or this is normal I would say the life cycle of us were a
software development methodology right. So once the bugs have been identified in
manual testing everything was given back to the developer saying that you know
these are the bugs please fix them. Now they were problems
in this structure you would say that this seems perfect but there are some
problems in this structure, let’s understand those problems. So the first
thing is that because it took a lot of time in integrating things and look at a
lot of times in in manually testing things developers used to work on three
or four features together and at once said twice in a six month time or once
in a six month time they used to commit their changes or to the source code
management system and then a manual integration with them because such a
large code bases there’s a manual integration took a lot of time because
there are there were a lot of features which had to be integrated and I’m just
talking about three developers. Imagine a company when there are 100 plus developers working in the company right and everyone is committing to the source
code management system now integrating that takes a lot of time and this was a
problem. So first you have to integrate that and of course after that you’ll
have to test him and testing was also done manually which again took a lot of
time and because of a lot of time in manual integration and manual testing it
affected the time when we will give the feedback back to the developer. Now
imagine you submit your work to the company but you have not got the
feedback how you work is and of course no person is perfect every code that
goes through the roof development lifecycle will have some bugs that will
have to fix right. So the developers used to wait for the bugs to come back from
the testing team and took a lot of time and this led to a big gap in the
software development lifecycle it took a lot of time to develop code or
to develop applications with respect to the features that were requested from
the application right. And because of this there was a high risk and
uncertainty when you look at it from the business perspective because you could
not pinpoint indeed which were near to the customer expectations it always
took a lot of time to make changes in our already existing application right.
So these were the problems before continuous integration and we had to
solve this time problem that we have so that
our you know our release cycles become shorter our work becomes more accurate
and because of this we came up with continuous integration. So
what is continuous integration exactly? So continuous integration is basically
the process of having shorter release cycles by creating small features in our
code and simultaneously integrating them to our source code management system. But
there’s a catch the integration and testing now happens automatically rather
than manually right and this is why continuous integration is such a high
pennant it benefits a lot of organizations because not only do you
have shorter release cycles that is your features are going out every day but
also you have automated integrations and automated testing because of which a lot
of time gets saved right. So how does the time get saved let me prove you using an
example. So this is a classic scenario of how things happen these days. So you have
a developer the developer finishes his code and he submits his code to the
version control system which is picked up by the continuous integration tool.
Now the continuous integration tool automatically deploys it on the testing
server and the testing server automatically has built suits which have
been defined for your application it tests all the features of the
application automatically and if there are any bugs which are identified
probably a test case failed or something like that it gives that feedback to the
developer and all this happens in a matter of minutes right that’s how fast
it is. Now imagine yourself in the earlier world when I told you it took a
lot of time to manually integrate things, to manually test things so you
used to get feedback in days if not us and in this case that is today you get
automatic feedback in a matter of minutes and this has led us to improve
our release cycles in such a way that today we are getting releases two or
three releases in a day. Earlier, we used to have releases
twice or thrice a year and now we have two or three releases everywhere.
Obviously, it’s shorter releases shorter features but that’s how powerful our
software development lifecycle has become with the use of continuous
integration and does not stop here right with more
mature continuous integration of with more mature DevOps model what happens is
if your test succeeds it will automatically also pushed onto
production right and this is the power of continuous integration.
Now obviously coordinates integration is just a concept if you want to implement
it, it always will it will be implemented using some tools. So we’re going to
discuss that in a few moments but before that let us summarize what we just
discussed right. So the advantages of continuous integration include frequent
commits and hence small feature updates to our website but every day or every
twice or thrice a week right we have automated build and testing that saves a
lot of time it gives the feedback instantly to the developer and also
because of this there’s a low risk and faster delivery of products when you
look at look at it from the business perspective right. Now like it was saying
that all of this is possible using continuous integration but continuous
integration itself is just a concept right. It can be implemented using
hard code tools and we’re going to discuss that in a few moments so
continuous integration is a topic for today and the continuous integration
tool that you’re going to discuss today is Jenkins. Now Jenkins is an open-source
tool which is basically used for continuous integration it is based on
Java and a lot of companies are working on Jenkins to get their day-to-day work
in the DevOps life cycle done right. So this is a brief introduction about
Jenkins and I already told you the features of continuous integration or
all of them pertain to what Jenkins can do in your life right. So without wasting
any time let’s go ahead and start with Jenkins by first installing it on your
system. So how can you set up Jenkins on your computer. Now there are set of
commands that you would need to run on your Linux box that would set up Jenkins
but there are two or three ways you can install Jenkins with. If you have Docker
installed on your system and you wanna just into testing, you can have Jenkins
installed in a docker container. So with that you do not have to set up your
environment with Java, you do not have you know go to the process of
downloading things just download that container and that would have Jenkins up
and running on your system right. But this is a bare-metal installation that
i’m going to show you guys, so let me just switch back to my server that I’ve
deployed on AWS to see how you can deploy a server on Jenkins. Alright, guys
so this is how my AWS server looks like so what I have to do is I have all the
commands written over here in my notepad so let me copy these commands, the first
command will basically install open JDK 8 on my system. So let me do that. Okay so
it’s unable to wait reason is we haven’t updated so let me update the system,
first sudo apt-get update and once that is done, I’ll install open
JDK 8. Alright so now it’s installing open JDK 8. Next step would be to copy this command
this will basically add the Jenkins key in the repository, so let us do that. Alright so this is done the next step
would be to install this command alright. so this is an exome and this would
basically add the binary of Jenkins to this list and now we’re going to update
so our repository links gets updated. and now let’s install Jenkins you alright guys so Jenkins is installed so
first of all let’s check these details for our Jenkins service so for that we
can check it using service jenkins status all right so the Jenkins service
is active so our next step would be to open the port of the ec2 server so let
us do that so the inbound connections let’s open all traffic to be on the
safer side if you want to be more secure kindly open port eight zero eight zero
because that is what Jenkins operates on alright and let me click on save alright
so this is done so now what I’m gonna do is I’m gonna come back to my dashboard
this is my Jenkins master let me copy the IP address and this IP address I’m
gonna use with the port 8000 to open Jenkins
so you can see the Jenkins dashboard is now visible so the first time you
install Jenkins you’ll have to enter the administrator password which can be
obtained from this part so what I’m gonna do is I’m gonna go to this path
and I’m gonna cut over there so this will basically so I let me do a sudo so this would
basically give me the password and let’s copy it and paste it over here continue is booting up so the first thing screen
that you would see is customized Jenkins so let’s install the suggested plugins
just for basically install all the plugins that we would require for
today’s session so once you’ve clicked over there your
plugins will start to install and we are wait a while until this finishes all right a next screen is going to add
Oscar for adding a user so let us do that let’s give the user name as in
telepath password as in tell apart when you filled out all the details
let’s click on save and finish and this would bring you to your Jenkins
dashboard so you would get the Jenkins is ready page and just click on start
using Jenkins all right so this is how your Jenkins
dashboard looks like and we’re gonna come back to this but before that let’s
just go back to our slides all right so guys we’ve installed successfully
installed Jenkins on our system our next topic would be to understand the Jenkins
master slave architecture right how does Jenkins work in the production in mind
is what we’re going to discuss over here so the think is master slave
architecture is basically important to accomplish continuous integration reason
being your testing will always happen on the testing server and your production
code will always be deployed on the production server right so you always
have to deal with multiple machines when you’re working in a DevOps environment
and that is exactly why you need two Jenkins master slaves so for in this
kind of situation where you have to deploy your code to the testing server
Jenkins becomes your master so and your testing server becomes useless server
for Jenkins right similarly your production server would become slaves or
for Jenkins and the master Jenkins will only have the Jenkins installation
Jenkins will not have to be installed on any other other systems which are
serving as the slave of Jenkins right the third thing is why do we need a
master slave kind of scenario so I’ve seen a lot of people basically just use
Jenkins on the same computer where they have to deploy the code as well and that
is because they are not dealing with probably parallel jobs of deployment or
they’re not dealing with complex bills and that the reason they have it on the
same machine but when you’re working on to the production environment you have
to have a master slave kind of an architecture where in the testing and
the production server would become slave for your Jenkins master all right so now
what we’re going to do is we over a set up master slave on AWS and let’s see how
we can do that all right so the first thing that we have to do is deploy two
servers on AWS that is slave 1 and Slade 2 and then we connected to Jenkins using
the jnlp connection so let’s see how we can do that so the first thing that I’m
going to do is let me jump on to easy to my admin console and let me
create two slaves you by specifying the number over here that
is too so we’re going to launch the instances
so our instances are launched let us rename them as slave 1 and we have our other witches slave do
now mind you guys we will not be installing Jenkins on either slave 1 or
slave 2 we will be controlling these slaves through the Jenkins master now
there are some settings that you will have to do in your Jenkins master let us
go through that so the first thing so this is your dashboard so the first
thing that you have to do is you have to go to click on Jenkins and go to manage
Jenkins go to configure global security once you’re here just scroll down and
you will reach this section which talks about agents now over here we are
talking about TCP port for genies be agents exchanged just two random and
click on save once you’ve clicked on saves now we will
go to manage nodes and now we will add a new node let’s name this node node as
slave 1 and now click on permanent agent and click on ok.now over here you will
have to add the launch method you’ll have to change
it to launch agent via Java Web Start and the current working directory path
specify that to slash home slash window and slash Jenkins alright just specify
this and click on save you will reach this screen so I’ll tell you what to do
after this for now let’s add one more new node
let’s name it as slave 2 and we’ll copy everything from slave 1 and click on OK
all right so everything is the same so the remote root directory would be this
slash home slash mundo and then Jenkins all right so slave 2 is also configured
let us check what we can do now all right so the next thing that you have to
do is now click on slave 1 and download the agent jar by clicking over here
alright so your agent or jar is now normally I had one before so just ignore
this thing so this agent dot jar is now downloading and now I’ll have to send
this file to my slave and so and I’ll show you how you can do that right for
now just click on show in folder remove the older agent rename this as
agent all right and now we’ll have to send
this to our slave 1 and the way we can do that is by first selecting slave 1
take the IP address from over here you’ll have to download a clock client
called FileZilla just open that in FileZilla paste the IP address over here
use name would be Ubuntu for the Ubuntu operating system port is 22 and in the
settings you’ll have to click on edit and then click on settings go to SFTP
and you’ll have to add the key file over here viable already added that just
click on add key file just go to your key file select that click on open and
you’ll be added over here this is important to connect because when you’re
connecting to EWS the only method that you can connect to is using your PEM
file or your PPA file and this is the way you can add it in in your files at
our browser right so once you have added that just click on quick connect and now
you will be connecting to your slave 1 so once you are connected you will be
given all the directory so here are all the directories now I’ll have to copy my
agent Gaad jar on my slave ones just click here and it will copy your file to
slave 1 ok so let us also verify that if our slave 1 has been copied or not so
let us connect to our slave 1 so we’ll connect it using this IP address let’s
go to put the click on your session connect to slave 1 and let us give a special appearance to
this let us give let us decide a color on this so let us
decide the orange color so the orange color is sleeve 1 so let’s click on OK
and let’s click on open all right so login as Ubuntu great so now if I do an LS I can see
that agent or jar has been successfully copied all right so slave 1 is done now
we’ll have to do the same thing for slave too so let us go to slave to
download the agent or char while it’s downloading just copy the IP
address for slave 2 enter it in FileZilla so that we can
connect to it right click on Quick Connect so you will have the directory listed
over here all right now we’ll go here and we’ll
rename our agent one dot jar two E’s in Georgia and the way we can do
that is like this so we’ll just go here rename this all right remove the older rating file and rename this to agent or job once
that is done just drag and drop it on the sole and now let’s connect the slave to using
booty so let’s click on your session as such add the file and let us keep the color for this slave
as white say all right so this is slave to as over you it’s the agent or jar file has been
copied successfully all right so now the next step would be
to basically go to your slave and you’ll have to execute this
particular command at the place where your agent or jar is present all right
but before executing this command will have to install open JDK on put these
swords that is slave to and slave one so let us do that so here is the open JDK
command let us pass it over here so we’ll have to update the server first
let us update it you all right and
is the command right so while Java is being installed over here let’s do the
same for us live one as well so let’s update it first you so it’s updated and now let’s install
JDK all right so while Java is being
installed on this I think we are almost done on our slave – all right so slave
to the jar the Java is installed so what I can do now is I can go to my champions
page and go to slave 2 and I can run this command over there now and this is
it the moment you run this command can you see it says connected and the
moment it says connected just come back here refresh the page and your slave 2
is now connected let’s do the same with our slave 1 just copy this command go to your sleep one clear the screen
and basis command all right so now both sleeves are
connected to your EWS Jenkins oval and you’re set so if you see the nodes you
have a master now you have slave one and you have slave two and this is what we
were supposed to do so let me come back to my slides all right so we have
successfully setup Jenkins master slave on AWS our next task is to basically
create a pipeline which would be triggered by get web hope to deploy a
project on Jenkins so let us do that so for that these are the steps that we’ll
have to do so basically we have a project I’ve created a project on my
github repository now this project has a drop of file and this docker file can be
built to basically deploy a website on docker all right so we’re going to
deploy a web site on our slave one first which will basically act as our testing
server it will be sudo testing kind of a thing right
and if our website is successfully deployed on us test server that is slave
1 it will then be get deployed on slave 2 which will be our production server so
this is basically a job and this should happen automatically so up get vibhut
basically means that the moment I commit on git it should automatically trigger
job on Jenkins it should automatically deploy the website on my website on my
testing server first if it gets deployed successfully then it should move forward
and deploy the same on my production server all right so this is what we are
going to do so let us quickly go to our github website to see how our code looks
like so basically this is my code guys I have the docker file I have the website
in here docker compose please ignore it we are not going to use it so we’re
going to use the docker file the docker file code looks something like this so
basically this is a container which it’s going to pull and after pulling the
container it is going to add the DevOps IQ folder inside the van www HTML DevOps
IQ directory that is this is inside the container alright so this is getting
enough and this will get deployed inside my
server once I trigger it from Jenkins in order to do this first we have to
install Jenkins on both the slaves as it is mentioned in the steps and like it
says like we’ll have to configure it in a way that if the build on Jenkins slave
1 is successful then it should be built on slave two once it’s done we should
finally trigger the job using get web hooks alright so let’s do this guys
let’s go ahead and start with the demo so that let’s see how it can be done
alright so the first thing that we are going to do is install docker on both
the slaves so let us go to put T terminal let’s go to slave 1 first now
remember guys you will have the connected state over here do not close
this terminal otherwise your connection will stop so what I’ll do is I’ll just
minimize it and I’ll duplicate the session so that I can work in a
different terminal all right so the first thing that we
have to do is install docker so let’s do that
sudo apt-get install docker dot IO okay so
installing now so while doctor installing over here let us do the same
on slave to so just duplicate the session and go to Punto now install dog you
all right so doc docker is being installed on slave – it has installed us
say one let us check so docker – I have inversion if we can do that that means
docker is installed yes docker is installed on sleep one
and is installed on slave to as well let’s check so sudo apt pseudo docker
version yes so docker is installed on slave 2
ways well awesome so our first job is done
we had to install docker now our next job is to configure Jenkins to build the
project on slave 1 if successful should be built on slave to so for this we will
have to go to Jenkins so Jenkins is over here and we’ll have
to create a job all right now you can check the status of your slaves over
here so you can see that master is idle slave is also idle and slave to is also
idle now first let’s create a job for our sleep one so a slave one basically
will have a pre side project and let us name slave ones job as slave one so
let’s name it as test okay and then click on OK
all right so the job has been created now the first thing that we had to do
was to copy our code to the workspace so let’s scope clone a repository or it
mentioned the repository link over here and by clicking it up project ok and
then go to source code manling click on kit and mention your repository over
here as well now because this job has to run on slave 1 we’ll have to just shit
where this project can be run and select slave 1 right so slave – job and they
seem to slave on once you select slave on this job will only run on slave 1 ok
once you’ve done with that the next thing that you would have to do is come
down and click on add build step but before doing this let us check if you
know my job is being built or my workspace is being populated by the git
repository content if I build this job on sleep 1 right so this would basically
test our connection as well so let us do that so let me click on build now and
this would basically start a build wherein it will copy the get content on
slave 1 ideally right so the blue ball basically tells us that the job has
completed successfully so let us click over here and I can see that you know it
has been successfully bein finished so let us verify that let’s go to slave 1
and if I do an LS over here great so I can see the workspaces there let me go
inside workspace all right so inside workspace let us see
what do we have we have test so this is the job name awesome so if you go inside
test do we have the git repositories content yes we do alright so my git
repository was successfully cloned into the test shop that basically means from
my master I’m able to build a job on the slave one node which is great so that
basically means our connection is working fine awesome so let’s go ahead
and go back to configuring our job right so what we want to do is we want to
deploy the website which is mentioned over here in this repository to my
project now the way to do that is by running this docker file right for
running this docker file I’ll have to check what is the present working
directory so my present working directory is this so let us copy this
and once you come back to Jenkins you’ll have to scroll down and click on add
build step once you click on add we’ll step click on execute shell what will
execute shall do so execute shell is basically used to run any commands that
you want to run on the terminal of the other machine that you’re trying to
build on Jenkins right for example we are trying to build on slave one from
Jenkins so what commands do we want to run over there so I want to run docker
build command so I said docker build and then hive dockable and then
the repository where the dockerfile is so it’s over here and then the name of
the image that I want to give so the name of the image would be say I want to
say it’s test okay so this is the image name once the image is built I’ll have
to run it so let’s run it on port 80 now so let’s turn it on port 80 – and then
let’s like this so this is the command for
running the docker image that you have just built right once it’s built the
next step would be to check whether it’s there or not we can do that on the
browser and I forgot one thing I’ll have to add sudo and because this job can be
build time and again what we’ll have to do is we’ll have to remove the older
containers which are running on the system right so for doing that I can say
that sudo talker RM – F and for removing all the
containers which are running I’ll have to pass in sudo docker PS – a and – Q
this should delete all the containers which are running inside my sleep 1 now
to check if my docker file is building my containers or not what we can do is
we can simply copy the commands from over here so the first thing that I want
to do is I want to build it let’s build medaka file
so the file is now being built awesome so it’s been built the next
thing that I want to do is I want to check if I want to run this command
right so for running it the command is this let’s copy it paste it over here
hit enter and my container is now running so I’ll have to check that if
it’s running or not so I go to slave 1 copy this
paste it over here so and port number is 82 so I can see the impossible that means
the container is working let’s check if our files are being sure or not so if I
go to develop psychic you folder yes I can see the website so means these
commands are running fine but what I have to do is I have to check
if it’s running through docker or not so I have configured the commands over here
and these commands are work on the terminal they should work over here as
well right so let us go ahead and save this okay so our job has been saved and the
next thing that I would do is let me remove all the containers which are
running over here so for that DUSU rocker PS let me remove this container so the container is removed now let’s go
ahead and run this container run this job all right so now let’s go ahead to our
Jenkins dashboard and let’s build the project now to see if everything goes
fine so I’ve clicked on build now all right so it gives me a field bill
let’s see what the problem is so the problem is
over here it says the first command sudo docker PS – da – cue rocker I’m require
at least one argument okay so I’ve got the problem so the problem is there is
no container running over here as of now right and that’s why it is not able to
remove any container and that’s why this it is giving me this error okay to solve
this what we can do is for now let’s in the configure part let us remove this
line or what we can do is we can start a container over there right so let’s run
any arbitrary container blocker run – 90 – D and then we’ll do let’s run it so
that there is a container running because ideally there will be one
continue running at least on my system so let’s click on save try to build the project okay so the build has gone successful
okay its forth checking that I’d say I’d say let’s just refresh this and yes my
website is being deployed over you so let me just do it one more time so
I’m sure it’s working so let me just do a docker PS you
sudo docker PS and let’s move this pseudo docker RM if an F remove this and now let’s run
our arbitrary continued let’s ensure that this website is now
not working so it’s not working now let’s rebuild
this project all right so now if i come here and i
refresh this yes so the website is working successfully awesome
so it’s works on slave 1 let us now configure the same thing in slave to
West Belle right so let’s come back to our dashboard so the test job this could
be our arbitrary test shop so basically we are trying to deploy it on a server
if it gets deployed successfully we are going to deploy it on the Proud as well
so let’s create a new job and let’s name it as prod free start project click OK
and the github project is going to be the same this one
let’s paste the URL over here and we have to restrict this to run on slave 2 great the source code management is
diskette repository and the build step also would be the
same so basically we want to delete all the containers which are running right
now so for that it’s sudo docker RM hyphen F dollar docker PS – II and I
think you okay next step is to build a file to do sudo docker run – 90 – P and
we want to run it on port 80 because it’s production right and the
image name is guest – Lee and – and before this you forgot
one command which is pseudo docker build and then the directory which is flash
home / 1 – slash workspace / the job name which is broad
and then over here it’ll the dockerfile would be pleasant and I want to name it
as say production the container name would be
production and over here also the container name would be production
awesome so let’s click on save and let’s now try to build it but before
that we’ll have to launch one container on test so let’s run an arbitrary
container you all right
so container is ready now let’s check by clicking on bell now if this job is
working fine so we have clicked on built now and if
you want to see the console output we can see it over here okay so it says job failed and the
reason for that is god permission denied okay so the problem is I forgot to add
pseudo so let’s add pseudo let’s add suit over you and that should
be it let’s click on save and let’s try it again okay again they have a problem but I
think it’s new error so let us try to resolve that so it’s unable to prepare
context and the path is slash home slash you’re going to workspace and fraud not
phone okay so let’s check if this path exists so we if you do an LS we have
Jenkins okay let’s go inside Jenkins if you do an address
okay so workspace is over here so basically I’ll have to change the path
to slash home slash 1 2 / Jenkins slash
workspace Brod – t and then production click on
save if we check if there is a container running on my slave if there is no continue running the lab
to run macho pseudo run – nightly – d12 okay container is
running and that is also ensure that we do not have any website running or not slave to okay so this is the command if you are
getting me this is the hope with the good getting right now all right
so let’s click on bill now and let’s see if I build a successful all right so it’s getting built let’s
hope for the best let’s hope it successful
all right so it gives us a blue sign blue means that build was successful
let’s try to refresh over here and yes it works now let’s just go to
DevOps iq folder and see if our website is up and running yes so our website is
up and running awesome guys now what I want to do is I want to
trigger so first I want to trigger prod job only when the test job is completed
now let’s see how we can do that so we’ll go to configure and let’s see if
we can configure this all right so I’ll have to go to – of actually let’s go to
the test shop let’s go to configure and over here I have to go to add post build
actions ok let’s click on that and after this we’ll have we’ll say build other
projects click on that and which project to build I want to
build fraud and trigger it only if the bailiffs
table so if the bill passes only then it should start with prod okay awesome
great so let’s click on save and if my test
gets succeeded then my fraud job will run alright so let us
check this as well so let me try running it so we can run the test job using the
pipeline view as well so if we you just have to come back to the dashboard and
over here you will find both the jobs let’s click on the plus sign that you
see over here and once you click on the plus sign you should be seeing a build
pipeline view option over here if you’re not so that means the plug-in is not
installed so let’s install that plug-in for that you are through click here go
to manage Jenkins and then click on manage plugins click on available and
then search for build pipeline build pipeline select it and then
install without restart just click on that all right and now Europe your plugin
will start to install on your Jenkins so all right so my build pipeline plug-in
is installed let us go back dashboard click on the plus side and you
can see there’s an option down which says build pipeline view select that and
name this viewers CIA CD or anything that you wanted right
click on OK all right everything seems fine over here bill
pipeline view title let’s name it as CI CD ok let’s click on okay you all right let’s check so in my CI CD
view I just see the broad job so let’s see how we can fix that so I want the
test job to also be there so let’s see so let’s click on configure and build at the projects after the test
is done okay you okay so we forgot to choose the initial
job so the initial job will be test right
and let’s click on okay okay so now it looks good so the first
the test job will be executed and then we’ll have the broad job executing okay let’s try running these jobs by
clicking on run you all right so as you can see our test
shop started and then our prop started and it completed so this completed in
1.5 seconds and this completed in 1.5 seconds as well and both of these have
these websites awesome now what I want to do is I want the moment I commit on
make it up this should trigger my Jenkins job so for doing that let’s go
over here that is my Jenkins dashboard and let’s try doing that
we test okay so we’ll click on test and we’ll click on configure all right and you
yes so in the bill triggers option just go to github hook trigger forget SEM
polling all right and just click on save the moment that’s done just come back
here on your kit hub so for configuring your web book all you have to do is
click on settings and click on settings go to web hooks inside my books click on
add web hook and now just copy the IP address and port number of your Jenkins
dashboard or your Jenkins page and paste it over here slash github – the book specify that and click on add
book if the response is received by gate and
everything works fine it’ll give you a tick which means everything is working
fine right and just go back to your dashboard
and you can see that everything works out great now what we have to do now is
we have to push a commit on github and that will automatically trigger a build
over here so let us check that so we’ll just open this over here and we’ll go on master let us trigger a build so this
build can be triggered from anywhere I’m just doing it on master for the sake of
simplicity so I’ll just do a git clone of your repository get clone
all right everything is now I have something on my I have a website right so what I’ll do
is I’ll change the contents of that website and let’s see if that content is
visible on a service as well so I’ll just change the index file
the first thing that I’m gonna change is the title so I’ll change this as Jenkins
Prada website okay and let us change the image as well so I have one more image
over there so let’s name the images to jpg
great so now let’s push this on docker hub so let’s add it committed all right and let’s push it now get push origin master the username and
the password all right so the push has been made let’s check if anything has
triggered over here so as you can see the test got triggered
and now the prod also got triggered so both the jobs have been successfully
completed just on a push let’s verify that so this is my so
let me see which one is my slave 1 so slave 1 is 1 0 8 so let us see ok so
this is my slave 1 let us refresh this and see which website is coming as you
can see the background got changed and as well as the
title also got changed similarly if this job is successful it should also be
triggered over here let us check if the website is also pushed here and yes so
job is also pushed here awesome so let us try this one more time and with this
let us try to bring back the same background that we had right so let’s do
a nano on index.html and let’s change the title to Jenkins
final website and let’s change the image name to one
dot jpg which was the earlier image save it
now let’s push it on github so we’ll add it committed and now let’s push it all right so our code is now being
pushed it’s been pushed now let’s come here and see what is happening so our
job should now be running so test got completed fraud is being completed so prod is running right now
and prod also got completed successfully awesome so let’s check if a website got
changed over here so this is my testing server so the title got changed and even
the background let’s see for a production and even a production website
got changed so awesome guys we have successfully completed what was asked to
us in the hands-on so we were supposed to create a Jenkins pipeline which would
basically if slave one job is completed should be built on slave 2 and the job
should be triggered by a gateway book and that we have done successfully so
thank you guys for attending today’s session I hope you guys learn something
new today so if you’ve got any doubts that you have that you’re doing this
session or if you’ve got any errors while doing the same demo as I was doing
you can push it down in the comment section we’ll be happy to answer it for
you alright so thank you guys for attending today’s session I hope you
have learned something new today so see you again in the next session good bye
and have a great day

14 thoughts on “Jenkins Tutorial for Beginners | Jenkins Tutorial | Intellipaat

  1. Guys, which technology you want to learn from Intellipaat? Comment down below and let us know so we can create in depth video tutorials for you.:)

  2. Following topics are covered in this video:

    00:44 Why do we need CI?

    04:24 What is Continuous Integration?

    07:51 What is Jenkins CI?

    08:24 Setting up Jenkins

    13:20 Jenkins Master Slave Architecture

    15:00 Creating Jenkins Master Slave on AWS

    25:43 Triggering CI/CD Jobs using Git Webhook

  3. ERROR: Error cloning remote repo 'origin' Finished: FAILURE

    When I tried building using invoke top level maven targets Kindly help me I am new to jenkins

  4. Error: Unable to access jarfile agent.jar
    When i installed open jdk in both the slave and trying to execute the command getting above message. Please help me to resolve this error.

  5. Hi Team,

    I have installed Jenkin on ubuntu.. but I am not able to connect to Jenkin UI from my remote windows machine. Both machines are in the same network and ufw status is inactive.. can you please help

Leave a Reply

Your email address will not be published. Required fields are marked *