Hello everyone welcome back to this session. So today in this session we're
gonna see how we can create an automated CI CD pipeline in Jenkins using the
jobs that we have already created right so I've discussed what CI CD
pipelines are and now let's see what all steps we'll be doing right. So these are
the steps that we will be following the first step would be to initiate a git
web hook for the Jenkins git job repository right so basically whatever
changes I'm making to git, that change should trigger the job git job
repository so let's see how we can do that right. So I'll go to my Jenkins
workspace okay or my Jenkins repository and what I have to do is I'll have to go
to settings once I go to settings I click on web books once I click on web
hooks I click on add web book okay so it needs my password again for this so I'll
confirm the password and now the URL. So what will be the URL, the URL would be
basically this right so I'll have to go inside
Jenkins URL which is this slash github - web hook, this you have to write okay so
once you've specified the IP address slash github - web hooke just click on
add web hook ok so I click on add web book and now basically this whenever the web
book will be triggered it will give you a green tick over here so let's check if
we can give a push so yes so you can see a recent delivery over here it says a
tick mark which basically means it was it was successfully basically able to
send a request over here on this URL so we'll just have a look - we'll go to web
hooks you can see there's a tick mark here which means that everything went
fine awesome now let's come back to a Jenkins dashboard and basically now what
I have to do is I have to trigger the git job right so I click on the git job
I will click on configure whenever there is a change over there this basically
has to be triggered so we'll specify this build triggers and
over here you have the option git hub hook trigger for git SEM poling just
specify just click on this and that's it guys that's all you have to do also
now once the git job is completed you want to execute another job so you'll go
into post build actions ok so inside post build actions we have this button
called add post build action just click on that and now we want to basically
build another project so what we'll do is I'll search for build another project
right so which we have this option build other projects click on this and we
should select the option trigger only if the build is stable if the build is not
stable or it did not complete successfully this should not be
triggered and what project do I want to build I basically want to build the
build website project right so this is the one I'll select it so build website
is the project that I want to trigger only if this particular job is
successful. Now I'll click on safe all right so my git job will be completed
and this will basically build my build website job and now I want after the
build website job, the website test job should be triggered right so I'll go
inside will build website job I'll click on configure ok I'll scroll a bit down
I'll go to post productions post production let's add a post production
which is build other projects and what project do I want to build I'm going to
build website - tests this is the job that I want to build ok and it should
only will trigger it if this build is stable because if my container is not
deployed anyways my testing will fail right so I don't want the testing to be
executed if this build is not stable. Now I'll click on save awesome so I have
successfully specified all the jobs or I have connected all the jobs the next
step is to basically view them as a pipeline right now for viewing them as a
pipeline just click on the plus that you have over here new view right just click
on that and over here as you can see there are three views that you have
right now list view and my view, there will be a third
option which would be build a pipeline view and in order to get that what i have to
do is click on manage Jenkins, go to manage plugins right click on available
and click in the filter search for build pipeline right this is the plugin that
we wanna install just click on this plug-in and click on install without
restart. So your plugin has now started to install let's wait for it to complete
awesome, so my plugin has successfully been installed now once I go back to the
dashboard now when I click on plus you can see there's a build pipeline view
now just click on the build pipeline view and let's call it first - CI CD
pipeline ok we'll click on OK and now we have the name, we have the description
now what we have to specify is this we have to specify. Select the initial job
right so the initial job will be good job this is what is being triggered
right by my Git web hook so this is going to be my first job this basically
when finish is successfully it will trigger the Build website job which
when successfully finishes it will trigger the test website job this
we have already specified right so you specify the select initial job over here
and that's it that's all you have to specify we'll click on OK now okay so
you can see that you have your pipeline like this right so you have a git job
first then you have your build website and then you have your website test ok
now this has to execute so this is the pipeline which has got created. Now
because the git job will only get triggered when you have committed the
code to git up now let me show you an awesome thing guys so what I'll do I'll
just clear the screen over here, exit the pseudo mode so I am into the website
git directory right now what I'll do I'll just do a nano on index dot HTML ok
let's add an h3 as well this is h2 let's add h3 and I will say
these changes are being deployed
automatically all right and I'll close the h3
I'll save this file if I check the git status you can see there is a modified
indexed or HTML so we'll push this to our github so get a dot git commit - M
and the job will be changed website
we have committed it and now let's push it to our github so the credentials are
these. All right so my okay so git has been my
commit has been pushed now you will see that automatically this job will get
triggered right so let's click on enable auto refresh so as you can see this job
is automatically started now right so this has completed now this build
website will start so this will start automatically as you can see this also
has started this has completed and now my website test will start so as you can
see my website test is being executed and my website test has also completed
successfully so all three green cards means that your pipeline has executed
successfully now we can check this so what we'll do we'll just go to our easy
to management console go to the slave let's open the website can you see these
changes are being deployed automatically automatically all your changes were
deployed right now if I again want to do say I again want to you know I will just
close Jenkins now I don't want to see Jenkins I will close my github also now
imagine yourself to be a developer now all you have to do is just clear the
screen do a nano on index dot HTML say I again want to add something right so say
I add one more h3 and I say over here this is another change that I want to
check okay so we'll close it
we'll save the file right we'll add the file to get up will now do a git commit
changing one more time okay the syntax error so changing one more time has been
committed now let's push this it push origin master the username is this the
password is this so now my my my my code has been pushed right now let's wait for
like five seconds my Jenkins already in the background I
don't have to go to Jenkins to check anything already in the background it is
executed everything things now right so let's wait for some time and then we
will try to refresh and see if I changes are being reflected over here so if I do
a refresh right now awesome so I can see that these changes have been
automatically been pushed over here all I did was I pushed on my github Jenkins
automatically got the change it it basically downloaded the code doc alized
the code deployed it tested everything and then this is what I see right so
guys this is how you create an automated CI CD pipeline this is automated because
you're not going to Jenkins anymore you're just changing your code and
everything is being deployed displayed over here automatically right so
congratulations on your first CI CD pipeline and with this guys we have come
to an end of our session so thank you guys for attending this module I hope
you learned something new in this module now in our next module we'll be talking
about cuban IDs which is module 9 right so see you in our next session guys have
a great day and good bye