DevOps Tools | GIT Tutorial For Beginners | Jenkins Tutorial for Beginners | Intellipaat

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys welcome back to intel parts day 2 of this devops series so now in this particular session we're going to look into two different tools which is git and jenkins and before moving on with this session please subscribe to our channel so that you don't miss our upcoming videos and also leave a like if you enjoy our content now before moving further let's begin with the agenda first let's look into introduction to git once that is done we'll be looking into git lifecycle and then get commands so once we complete all of this we'll move on to jenkins and then we'll look into jenkins installation and the jenkins architecture and finally we'll be showing you how you can set up a ci cd pipeline using jenkins so that would be the last part of this particular session so without any further delays let's begin with it so before moving on with the session please subscribe to our channel and also hit the bell icon for the upcoming updates from our channel and also if you enjoy our content you can leave a like all right guys so now let's go ahead and understand what is git so guys git is basically a software which helps us in doing version control right and it's a distributed version control system so we already understood what a distributed version control system is so it's a distributed version control system which basically helps us to version code files okay now uh if you if you go by the definition it is used for tracking changes in computer files or the code files and also coordinating work so uh any project or any product like i said when you work on it it's a team's effort it's never one person who handles the whole product it's always a team effort and git basically promotes collaboration right so if you are working on a project there can be multiple people who will be basically working on that project moving forward now let's go ahead and talk about uh the git life cycle so now that we understand what a distributed version control system is we understand that we are going to discuss about git which is yes another distributed version control system we understand the advantages of using it now let's go ahead and understand how does get basically work so when we talk about the life cycle of kit uh to sum it up quickly there are three stages in git through which a basically uh you know a code file goes from right so when you start working and get you know you basically start off to work in the working directory so any directory that you start to work off in that's basically your working directory once your work is done what you do is you stage your work you make it ready for uh being saved on the version control system right so you kind of simulate all the files or you basically promote all the files which you want to be uh which one you want to be saved in the version control system for example there could be 10 files that you're working with right uh for example some could be input files some could be output files right and some could be the code main code files that you're writing in your working directory but when you talk about uh you know saving your project you want to you want to talk about saving your code actually you will not be saving the input and the output files you will only be saving the main code files which are there in your working directory so when you are basically going from a working directory to the staging area what you're doing is you're selecting the files that you want to save in the version control system so when you select those files that you want to save that becomes the staging area so in the staging area basically for the files that you want to go ahead and save in the version control system and finally what you do is you save them and the saving term or the saving process is basically called git commit all right so let's go ahead and understand these life cycle stages one by one so first of all we start off with the working directory so any directory which has uh your code file in it and which has get initialized in it is basically called the working directory if i were to quickly give you uh you know a glimpse let's say i go to my terminal and let's say create a directory let's say the directory name is learn okay i go inside learn and inside learn what i do is i do get in it so what does get in it basically means get in it basically means that i've initialized a git repository now once i initialize a git repository this folder learn has now become the working directory for me right so it doesn't have anything right now so i can put some uh i can put some out output files here i can put some input files here and then i can put some uh code files here right now these input files and output files i don't want to save i just want to save the code files so the way i can save the code files is by typing or bytes is by staging the code files and the way i do can do that is using the git add command okay so we'll be discussing more about it as we move along but yes so just to be clear what the working directory is once you initialize git this folder where you initialized it it becomes your working directory right so the place where your project resides in your local disk is your working directory this project may or may not be tracked by git for example if i have done git init this is being tracked by git right now but let's say you are creating a new project and yet you have not done git in it okay so still in that case technically that's your working directory because you have all your files over there so once your project is probably at a stage where you feel it has to be shared with someone or it has to be uploaded somewhere in that case even if you do get in it in that case as well it will be called as a working directory okay uh by so the project can be tracked by get by using the command git init so that i just showed you once uh you know you start working on a folder you just type in git init and then that folder becomes initialized and that folder becomes your working directory and by doing it in it automatically creates a dot git folder so over here right now if i do an ls you are not able to see a folder called dot git right so if i do ls hyphen a you can see there is a folder called dot get so this is the hidden folder in your working directory and this hidden folder basically has all your settings it has all the versioned files that you will never see uh you know when you are working in a working directory your working directory is always clean and all the settings of get all the versions that are stored in git are stored inside the dot get folder if you accidentally delete the dot get folder your git version control system is done with all your version files will be deleted all your logs will be deleted so that's why this file is folder is very important and that's why this folder is hidden okay so that's that's about the working directory and then you have the staging directory guide so staging directory is basically the directory where you set which files you basically want to save in the version control system right so i give you the example of having a lot of files but among those files let's say three or four files are the main files that you are the code files that you want to store as you know in your project repository so for saving them in the staging area what you do is you use the git add command right and by using the get add command you basically specify which files are going to be tracked by git specifically okay then you have something called as commit so commit is the final stage of the file in a find the lifecycle stage uh you know of a file being saved on your local hard disk wherein when you type in git commit whatever files you have staged in the staging area will now be saved in the git file system uh you know locally and that is possible using git commit so if you if i were to explain the whole process to you using a diagram so first thing what happens is you are in a program workspace in this program workspace what you do is you initialize a repository you're using the git internet command now this git initialized working directory the uh where you complete all the code files and then what you do is you specify all the code files that you want to save and then that becomes the staging area for you and once the staging area is ready with all the files that you want to save you pass in the git commit command and the files get committed to your git repository but is this the end so we were talking about the fact that git basically promotes collaboration so let's understand how that is done so once your files are now committed to your local repository what happens after it how do we collaborate it with the team so that's when the concept of github comes so github is basically the remote repository of the distributed version control system that we were learning about so in distributed the version control system you as you know you had a remote repository then you had a local repository and the developers used to work in the local repository so github is going to be the remote repository in this case uh in so besides github there are a lot of other products also that you can use for example there is something called as bitbucket there is also something called as a git lab there are a lot of other projects as well right but all of them basically work exactly the same right from a developer's perspective from a devops architect perspective all the commands are going to be the same that you are going to learn today as well forget it's just that the remote repository can be a different software where you are uploading okay moving forward now let's understand how does git basically work so let's say uh i have a folder i have this working directory where i have different kind of files i have some html files i have some javascript files i have some json i have some csv i have some xml so this project folder first i initialize i stage all these files that i want to save and then what i do is i pass in the git commit command now when i pass in the git commit command what happens is all these files will now be saved inside the git version control system and get what it will do is it will assign it a commit id okay so this circle that you see here is basically a commit id it's basically a pointer to all these files which you have just created or which you have saved in your git file system next what happens is let's say you do some update to your code let's say we added a css file over here so the moment you add a new file and you save it again to get what git does is it again creates a new commit and it again gives it a new id so mind you guys you already had a commit id in place and this is always going to be there it's not getting deleted anytime soon this will not be modified always a new commit will be created right and in this new commit the changes will be saved so mind you mind the language that i'm using it will only save the changes so these six files that were there these six files are there in this commit so when you add or modify anything only the modifications are now saved in the new commit that you have right you don't have all the files saved all together again so with this concept what happens is you also save space right so you save space because time and again you're not saving all the things again what you're doing is you're only saving the changes so in this case this changes are the css file so only this css file will be saved in the comment but when you talk about the whole project that project is going to be a combination of this commit id and this commit id okay now because this project is going to be a combination of a lot of comments what happen is you put all these commits on a branch okay so what is a branch a branch is basically a logical or a sequential straight line which has sequential commits on it and whenever you want to see your code what happens is your code always is on the head which basically is the latest uh you know version of the branch so right now if i want to see what all files are there in the project directory what i do is uh i will do an ls and the ls will always happen on the head of the brand so head is always pointing to the newest commit which has happened on the branch so when i point to the head what happens is i see the changes and along with the changes i also see the files which were there in the previous comments okay and to logically uh basically uh go ahead and have a visual representation of for it we basically have a branch on which all the commits are basically arranged moving forward this branch by default is created and this branch is called the master branch so no matter which get software you might be using for the remote repository or no matter which product you're developing using it you will always have a master branch right and when i say a master branch you can have other branches as well but in case if you don't have other branches you will always have the master branch the master branch is the default branch which is present in all the git repositories okay okay but why do we need a branch so i told you for the visual representation for arranging the commits you need a branch but is that the only use case of having a branch or are there any other things as well that you can do with the branch so yes there are other things as well that you can do with the branch and let's go ahead and understand that all right so why do we need a branch so guys let's say we you are a developer right and what you do is you basically have been hired by someone who has already created a prototype of the project let's say i'm a developer i created my project and now i feel that it's time for me to scale up it's time for me to basically get the project running faster and so what i do is i hire a bunch of developers so how do i make them collaborate to my project so the way it works is what i do is i put my project on a master branch and i put it on github now i don't want the other developers since i do not know the capability of other developers uh let's take a scenario here that i do not know how well the other developers know how to code so what i do is i don't give them the access to my main code i basically create a copy of the code and i tell them all the rnd all the research and development that you want to do do it in this particular copy of the code right and when you think the task that i have given you is complete get it reviewed by me and then what i do is i will basically take the changes that you have done in that folder and i will integrate it with my main code okay let's take this scenario so in this scenario the main code is basically the master branch the copy of the folder or the copy of the main code that i give you is the feature branch and what the developer will basically do is he will start working on this branch so branch is basically a nomenclature but in other words it's basically a folder that you create in git so you have a master folder and then you can create multiple other folders where other developers can work so in this case if i hired one developer let's say i asked him to develop or change the ui of my home page so i add a feature a folder which i say is this this is the folder where the new ui will be added and worked upon by a new ideo developer so uh what i do is i create a new branch copy the master branch code over here and now this new developer starts working on this branch okay so when his work is done he commits the code into a new commit id which is zero zero four and once i review it once everything looks good to me what i do is i merge it with my main code which is the master branch so this is a very simple workflow of how you know collaboration basically works in gate so since you have one developer over here what you can also do is you can have multiple developers who can be working on multiple branches so you have feature a branch you can have feature b branch feature c brand feature d branch and all the developers can then work in parallel for different features and as and when their features are over i can just merge it back to the master and this is basically the crux of how it works now let's move on and talk about some of the common git commands that you will use in order to make use of kit so basically we've divided all the commands that you could be used frequently or you will be using frequently among these four domains right the first domain is about creating repositories so we'll be discussing some commands which will help you create a repository in git then we'll be dealing with commands which can help you make some changes and get then we'll be dealing with commands which will help you do parallel development and get and then towards the end we'll also be learning commands which will help you in syncing your repositories okay so let's discuss each of these domains one by one so let's talk about how to create repositories let's start from the scratch right so our first uh whenever you start a project the first thing that you have to do is you have to go to your working directory and you have to do some code or make some code right so the first thing that i'm going to do is let me just switch to my terminal all right so this is my terminal and i'm logged into an ubuntu server so what i'm going to do is i'm going to create a directory which is say called devops okay so let me create a directory called devops and let me just cd into this directory okay so i'm into this directory now let me just clear the screen now let us add some files say i had a file called nano uh let me add a file called one dot txt okay and let us say hello world in it so this is our first file okay now let me add one more file let us hear a file called nano glue dot exe let's say hello from intel apart okay so this is the file that we have added now let's save this file okay so now we have two files which are there inside a folder devops okay so this is not being tracked by git as of now right but it is still our working directory now in for making it a git initialized working directory all i have to do is type in git init and hit enter okay and now we have a initialized git repository in front of us okay so this is how you can initialize a directory and get so now you have created a repository in which you have your code which is now which will now be tracked by git let's come back to our slides so this is exactly what we wanted to do we wanted to initialize a git repository and we have done that we have added some files in that directory now let's go ahead and see what our next command is so our next command is about knowing the status of what are the files doing in that directory are those files saved and get what is the status of that directory and the command for seeing the status of directory or the or the files inside it is the command git status so let us quickly jump back to our terminal let me just clear the screen and now if i want to see like if my files are being if i'm if i have saved and get what what exactly is happening with my files so what i do is i just type in git status and i can clearly see that my files are right now on track okay why are they on track because i've not staged them yet these are just files which are which the git is seeing that you know they exist in the directory but they have not been added to my file system yet so this is what git is telling me right now okay it is also telling me if i want to track these files all i have to do is get add and then the file name so i don't want to do that right now so let us go back to our slide so this is what git status does it basically gives you a status of your repository or of your directory what are the files which are in the directory i mean what is the status of those files okay so we've got the status and next command is about adding right so basically we have made some changes to our file and now we want to add it into a repository and for doing that all i have to do is just go back to my terminal and i'll say git add i can either type in the name of the files so say i want to track both the files so i'll just type in one dot exer2.txt you type this or what you can do is you can just type in git add and then a dot dot means track all the files which are present in this directory so i'll hit enter and now if i do a git status let me just clear the screen if i now do a get status i can see that my files are now being tracked okay so my files are now being tracked they are staged right so in if you think about the life cycle you were in the working directory now you are in the staging area you have staged your files you want these files to be saved in the git file system they're still not saved they're still in the staging area the next step is saving these files in the git file system and for doing that the command is get commit okay so how do you type in the git commit you type in git commit then you give a space hyphen m flag which basically means the message and then you type in the message um that basically would point to what you are basically doing in that comment for example in this case this since this is our first comment we can simply type let me just clear the screen get commit hyphen m we can say this is our first comment adding one dot txt and two dot txt okay so this is what we do we just hit enter and now you can see that my files have been committed to get okay and now if you do a get status if i do a get status now you can see it says on branch master there is nothing to commit working tree is clean that basically means all the files which are there in this directory right now are clean they are all saved in the guide get file system and there's nothing to worry about not right now right so now let me just let's do a little experiment what i'll do is i'll add one more file let me just create one more file and let us name this file as three dot txt and type in test file inside it right so now what happens so if i do get status you can see it will say that three dot txt is a file which is untracked rest all the files which are there it is not listing that because those are already saved in git and they are uh i mean there there's nothing changed to those files also let us try by changing you know the two dot ht file which is not listing over here right so what we'll do we'll just do a little change to it let me just add one to over here let us save it and let me do a get status now let's see what happens so if i do a git status now it can see we have there is a modified 2.txt file and there is an untracked file which is three dot txt okay so this is something what you get so any changes that you can do to a file it will be reflected in the status of kit now if i want the two dot txt file to be saved i have to stage it again and then i'll have to commit it okay that is the only way i can modify the two dot txt file okay so let's come back to our ppt now and let us go ahead and see what is our next command so our next command is about syncing repositories so now we'll be so we have committed the files to our local system but how do we make it available to the world right so for making it available to the world the first thing that you have to do is you should have a git repository okay so let me just jump on to my browser and then i'll show you how you can create a git repository so just give me a second okay so guys you just have to sign up on github and once you sign up this is how your page would look like now what i want to do is i want to create a new repository so on your left hand side you will see a button called new repository just click on that right and now let's name a repository something so let us name it as uh devops and hyphen course okay so our repository name is devops course and the type of this repository is public and let us just now click on create repository okay so our direct repository has now been created and now what i have to do is i have to copy this link this is a https link guys so i have to copy this link let us copy this link and now let's come back to our ppt to see what exactly we have to do okay so now to add files to this repository or to push files to this particular repository first i have to add it in my command line now for adding this repository in my command line i have to type in the command git remote add origin okay this is the command git remote add origin and then the url to the repository so let us do that in our terminal so i'm here so right now when i'll commit basically my one dot txt and two dot txt will be saved my modified two dot exe file and my three dot ext will not be pushed okay so let us see if that happens so now what i'll do is i'll type in get remote add origin and then the url of my repository so the url is this let me copy that this is the url and i'll hit enter so now my files or my origin url has been added in my command line right it has been saved in this git repository uh my command line that is working on my git repository okay so now let's come back to our slides so we have executed this command let's see what our next command is so our next command tells us how to push files to my url right so the command is git push origin master and see guys this is the output for your command now when you type in this command get push origin master it will ask you for your username and will ask you for your password so let us do that so let me come here and let me type in the command so the command is git push origin master okay i typed in this command it is asking my username let me enter my username it is asking my password let me enter my password i'll hit enter and as you can see it is pushing the files and now my files have been successfully forced to my repository let us check that let us come back to our browser okay and let us refresh the page so as you can see it just says six minutes ago the files were committed to the repository and now they have been pushed right and over here you can see the message of my commit which was first commit adding one dot txt and two dot txt so you get the message over here here are the files so you can see the changes or you can see the content of the files as well if you click on one dot txt my one dot txt had the content hello world so it's being reflected here similarly if i want to see my two dot txt i can see that it says hello from and fell apart right so everything is here everything seems to work fine and again what i can do is now if i do a get status you can see that there are two files which have not been added so what i'll do is let me first make um or let me add first the two dot txt file that is at modify2.txt file into my git repository so what i'll do is i'll type in the command git add to dot txt let me hit enter so now this file has been staged right so if i do a get status now i can see that this file is now staged okay but this is still on track so we will deal with this later okay so now i have a modified two dot txt file and all i have to do is git commit and now i specify the message as modified to dot txt okay so this is the message that i'm passing i'll hit enter and now my file has been changed but these changes have now been done to my local repository not to my remote repository so if i come back to my browser and if i refresh you can still see the file which was added.2.ext it still says hello from intellipart and it was committed eight minutes ago right so it still is not added to my remote repository now to add it to my remote repository all i have to do is get push origin master okay i'll hit enter it'll ask me my username i'll provide the username and the password and now my files are being pushed to github it has successfully done that and now if i do a refresh over here you can see that it says that 2.txt was committed a minute ago right and you can see the message over here it says modify2.txt right and this is exactly what we did so we have added the second file as well to our remote repository let's add the third repositor file as well which is the three dot txt over here so we'll do a git add dot get commit hyphen m adding three dot txt and now we'll do a kit push origin master test your knowledge of git by answering this question which of the following command line environment is used for interacting with git a git bash b github c get boot d gitlab comment to answer in the comment section below subscribe to intellipack to know the right answer now let's continue with the session we'll give the username we'll give the password and now my file has been pushed and now if i do a refresh here i can see even three dot txt has been added with the commit message adding three dot txt okay so guys this is how you can push your files or you can sync your remote repository to your local repository okay so this was the command for that let's move forward now and let's check whether um you know the and you know this step i've already done so basically you can see that i have now synced my local to my remote repository i have you as you can see in the browser okay now let's go ahead and see what our next step is so our next step is to basically show you guys how you can clone a repository okay so this is when i have basically uh you know i have pushed my local repository to my repos depository now say you are another developer who is work who wants to work on this code now how can you work on this code all you have to do is click on clone or download and just copy this link okay copy this link go to your terminal right and let me create a folder say test over here and sorry let me create a folder called test over here and let me go inside the test folder okay now what i'll do is i'll type in the command git clone and i'll give the url and i'll hit enter now what it has done it has successfully copied the directory over here so if i do an ls i can see that the directory has been copied or my repository has been copied to my local okay and the awesome thing about this is now if i go inside devoxx course the directory now over here i don't have to basically add a remote origin right because you have cloned the repository so this directory automatically knows where if i push any file where it has to go for example if i create a file say i create a file nano four dot txt i say test file for clone okay i'll say that and now what i'll do is i'll add this i'll commit this by adding clone file okay i'll hit enter so my file has been committed and now i'll do git push origin master i'll give the username i'll give the password and as you can see my file has now been pushed automatically okay so if i do a refresh here 4.txt has automatically been added and i did not do a get remote ad origin even if i am in a different directory okay now let me show you what i exactly mean if i create a say a folder say i create a folder called test okay test exist let me create a folder called hello okay and if i go inside hello and if i do a git in it say i didn't get in it and now let me say create a file called uh hello world dot txt let me add any arbitrary text into it now if i do a git add dot and if i do a git commit and i'll say let's adding file okay so the file has been committed now if i do a get push origin master it will give me an error see it says origin does not appear to be a git repository why because i'm in a separate directory right now okay now if i do a cd i go inside test which was my first directory where i created all the files so over here if i do a git push if i add a file say let me first pull everything okay so because the get full origin master okay one second guys okay so i think this is now the repository okay so the positive was devops so let us go into inside devops and let me just create or let me just say google origin master so this is the directory where we first created a code okay let me hit enter so now it has as you can see it has added four dot txt to it because earlier we added in a separate folder right so now it has created four dot txt inside it it has added four dot txt inside it and if over here you can see i have not specified what origin is it automatically knows what origin is why because devops is a get initialized repository okay similarly when i said that hello is a get initialized repository but in hello i'll have to specify what is the origin of that repository right but if i do a git clone as i did in test right i went into test and i did a git clone of the devops course when i do a clone it automatically copies the parameter as well as to what my origin repository is okay any files that i had i if i push it on origin master it will know where exactly it has to go okay so this is how git clone can be helpful to you all right coming back to our slides so now we know how to clone a repository in kit uh we also saw how to pull uh you know uh files in git but let me show you again so basically what we want to show you is that say you are inside this folder devops course which is the same repository as what you have let me just duplicate this session all right so this directory which is devops is pointing to the same repository as devops course okay now if i do an ls here i can see that there are four files and four dot one.txt2.tc3.txcn4.txt similarly over here i have four files one dot txt two dot exe three dot example dot exe what i'm gonna do is uh let me add a file from here so nano five dot ext and let me say test file okay i've added it let me say git add dot so i've staged the file let me commence the file test okay i have committed the file and now let me push the file to my remote i'll enter the username the password and now my file has been pushed okay so if i have updated my remote repository this local repository of mine will not get automatically updated as you can see it can it will not get automatically updated if i do an ls over here i can see there are five files and if i go here on my remote repository if i refresh i can also see here are five files but imagine this to be one developer and this guy to be another developer now this developer will not have the updated files till he does a get pull okay so if he wants also the updated files which have been put on my remote repository all he has to do is he has to type in get pull origin master hit enter and now the files will be updated in his system okay so if i do an ls now you can see that five dot txt file has now been added to this uh directory as well okay so for coming back to our slides so get pulled helps you in updating your repository to the latest commit which is available on your remote repository so that is what get pull is all about and the difference between git clone and git pull is like i told you guys git clone is basically used when you want to copy the whole repository at your local system but if you want to update repository when you're working in it if you want to update all the files which are inside it you can use get pull in that case clone will not serve the purpose okay moving forward now let's talk about branches now as you can see uh now we are talking about parallel development okay and as we learned in our previous topics our previous sessions that if you want to do uh parallel development or if you want to assign code to multiple developers you basically branch out right you br you create a branch in your repository and you assign that branch to the developer who would be working on the code okay so let us see how you can create a branch in kit so for creating a branch engage this is the command git branch and then the name of the branch okay so let us see if we can create it over here what i can do is let me just clear the screen okay and let us say i created a create a branch which is something like this um get branch and say i create the branch of feature one okay so the branch has now been created now if i want to list all the branches which are there i just have type and kit branch and i can see uh there are two branches in my repository now one is called the master branch and the other one is called the feature branch okay now any developer who wants to work on on this code can basically work on this branch and when he feels that his work has been finished he can basically merge this branch to master and merging means that whatever code you have added to feature branch will also be added to the master branch okay don't worry if you're not understanding as of now you'll understand as you move along okay so i have added a branch feature one now if i want to delete a branch again all i have to do is get branch hyphen d and then feature one okay so it says deleted branch feature one that's it okay so now your branch has been deleted okay and this is exactly what it what we wanted to do moving forward now if you create a branch and you want to switch to that particular branch the command is get checkout okay so now let me create the branch again get branch one so i've created a branch and what happens when you're branching basically the last commit of your master becomes the first commit of your feature branch whatever you have created whatever branch you have created the last commit of your master becomes the first branch of your branch that you have created okay so for example in my master you can see that there are five files so now if i go inside if i do get checked out into feature one so basically now i have switched to the branch feature one and if i do an ls over here you can see there are five files okay now what i want to do is i'll add a file say i add a file six dot txt over here okay and i say hello world okay and what i do is i save the file get add dot i stage the file and now i come up the file added to feature branch my file has been committed and now if i do an ls i can see there are six files now but mind you guys this is not on my browser manager now if you want to see which branch you are on just type in git branch and you can see you are on the feature branch right now okay now what i want to do i want to check if my master branch also has these changes so what i'll do i'll just switch to my master branch get checkout master i'm on my master branch now and if i do an ls over here you can see that the six dot txt file does not exist here okay reason being my feature branch is isolated from a master branch whatever changes i'm doing on my feature branch it will not get reflected on the master branch whatever i do okay and whatever i do on my master branch will not get reflected on my feature branch it works vice versa okay guys so this is a feature which you basically use when you want to do parallel development so that no branch is uh i mean it is interfering with each other so now i don't care what my developer is doing on feature one when he says that the feature is complete i'll ask him to show me and when he shows me the feature and i feel it's right what i can do is i can merge it with my master so that it becomes available to the world okay okay all right great now if i do get status here you'll get status uh once again get status it says on branch martial nothing to commit if i check out the feature yeah so if i have switched to feature now now all i have to do is i will type in git status and it again says on branch feature one nothing to commit why because i've already committed 6 txt to it now what i want to do is i want to push this changes to my remote repository so what i can do is get push origin feature one why because now we are pushing the feature one branch we are no longer pushing the branch uh the master branch we're pushing the feature one branch right and i'll hit enter so it'll ask me the username i'll hit that and it'll ask me the password i'll put that and i'll hit enter and now you can see my files are being pushed and now you can see that feature one branch has now been pushed to feature one branch of my just a quick info guys intelpad provides devops online training validated and certified by nasscom future skills and ibm the course link is given in the description below now let's continue with the session remote repository so if i go to my browser now and i refresh it you can see the five dot txt is still not visible here why because i'm on my master branch i'll click here i can see that i have a feature one listed over here i'll click on that and now i can see that the six dot txt file is visible here and with my commit message which was added to feature branch okay so i can again switch to my master branch and i can see that my master branch is clean if i switch to my feature branch i can see that my feature branch is having the 6.txt file okay let's come back to our slides all right guys so we have we now know how to switch to a particular branch now let's go to our next slide now we probably know all the commands through which we can probably start working on git right this this command is a very important command which is get lock command now what is get lock command now get lock command helps you to see the history of your repository like what all have you done on your repository okay now to see the history of your repository the command is get log now let us go back to our terminal and let us just clear the screen now if i do a git log here i can see the history of all the comments okay so i can see that i am on my my head is on the feature branch right now right and i can see that the last comment was this when i added six dot txt to the feature branch before that i had a test commit before that i had a clone file that i added before that i had some other commit three dot txt 2 dot txt right so similarly i get everything i get a history of everything that i have done so far right and these are all the commit ids guys this is what we studied earlier right so if i want to say revert to this commit all i have to do is just copy this comment id and i have to type in git revert along with this id and i'll be able to revert to this particular comment but we'll do that later we're not doing that right now we'll do that later but this is the history of your branch okay now if i want to see uh the history of master this is the history of feature one okay let me just clear the screen and let me see where i am right now so i'm on feature one so if we go to get checkout and then master and then clear the screen if i do a catalog over here it you can see that the head is now on the master and only the log of the master branch i'm able to see right now okay i cannot see the log of adding the feature file why because i'm on the master branch now so whenever you do git log you always see the log of what branch you're on okay so right now i'm on the master branch and that's why i can see all these logs if i am on the feature branch i can see all the logs of the feature branch along with the logs of master branch when the branch was uh when basically uh the moment i create a branch in my repository it gets created from the master branch right so say i did three commits before i created a new branch those three commits will also be a part of my new branch that i've created and if i go inside that branch and if i do a git log i would be able to see those three comments in the log as well why because those three commits are also a part of those of that particular branch okay so but the moment i do any other uh comments on master those uh logs of that commit will not come in my feature branch reason being now my feature branch is separate all right so i hope this is clear all right coming back to our slides guys so we now know how to see the history of our uh you know our git operations our next command deals with get stash okay so what is git stash so whenever you're working with multiple branches there could be a point where you don't want to basically commit the file the file is basically still not complete right but you want to switch to another branch because you want to probably to fix something in some other branch where you're having a problem right so basically it's about multitasking it's about putting on hold the work that you're doing right now completing the work over there and then coming back here again and then starting with your work right so let me exactly first show you why do you need the git stash command okay so if i'm over here right now let me just clear the screen okay so let us create uh let us see where we are right now so if i do a git branch i can see i'm on the master branch right now okay so what i want to do is i want to create or let me just switch to my feature one branch and let me create a file called seven dot txt let me name it as slash file check okay so i have created a file but this file is still not staged it is not committed yet right so i am on my feature branch right now so if i do an ls i can see seven dot txt is here now if i change my branch what will happen let us see so if i do a get checkout master and now if i do an ls you can see the seven dot txt file over here why can you see the seven dot txt file because this file is not being tracked right now it is not a part of any branch right it because it has not been saved yet correct so what i can do so let me just come back to my feature branch what i do i'll just i'll just add or i'll just stage this file so let's see what that happens then right so i'll do a git add dot right and now the file has been staged but it's still not committed right so if i do an ls now it has all the files now if i check out to my master and if i do an ls here i can still see this seven dot txt file now this can become a problem or this might cause a confusion when you're working within branches or when you're working with production code because you don't want this file to be here when you're on the master right because you don't want your code to go haywire or cause a problem because of an extra file or probably you know you change something in five dot txt let me uh give you an example let me check out uh to my uh feature one okay and let me go to five dot txt so this is my five dot exchange it's there in the master as well let me change the contents of this file okay so i've changed the contents of the file i'll stage it okay and i'll do and get checkout master okay i'm on my master branch now i'll do an ls and now if i do a cat.5.txt can you see these changes are also there in the master i don't want that i don't want that to be reflected over here because my feature branch should be different from a master branch now to avoid this confusion although this file is not it's not saved on the master yet right it is just being reflected over here reason being these files are not committed to your bra in your respective branch where you were working okay so how can you avoid this now the way to avoid this is you would just check out or you would just check out to your feature branch where actually you want this file to belong okay and it tells you that you know these two files are there which have been this has been modified and this has been added okay so it gives you a notification which is good now what you'll do is you'll say get stash you'll just say this and hit enter now what will happen now if i go to my master get checkout master okay and if i do an ls i can see the seven dot txt file is no longer visible over here okay and also if i do a cat on five dot pxt i can see this this is the original file that the master should have right now say i want to wanted to do something in my master branch i'm done with that work now i want to get back to the work that i was doing in the feature branch so what i'll do i'll just do a get checkout feature one i'm back here i'll do an ls so right now the files will be not saved so if i do a cat.5.txt it will still be the test file it will still show me the committed version of the file i mean if i want to restore the files that i was working on all i have to do is get dash and then pop this is the command to basically come back to your working state so i'll hit enter i'll clear the screen and now if i do an ls i have seven dot txt and if i do a cat on five dot txt i can see this is the modified five dot txt so i'm now again in my working state if i do a get status it will show me that you know my files have been staged but then they have to be committed now okay so now all i have to do is i'll say git add dot and now i'll commit these changes committing stashed changes and now these changes have been committed to my feature branch right and now if i do an ls if i do a kit status i can see that my branch is clean and i can now easily just go back to my master i don't have to stash anything anymore if i do an ls it is still isolated reason being everything is committed to the branch now and there is no dangling files there and there which could confuse me with the files that i'm working uh in whichever branch i want okay and this is why we use the get stash command so so that we don't have any confusions the files don't get mixed up with the files of other branches and we don't get confused okay so guys this is this was the git stash command let's see what our next command is so our next command is git revert okay so this is an awesome uh feature of git so let us come back to our terminal okay so what i want to go do is i'll just do a git log and i have all these comments over here right so i want to go back to my first commit where i just had my one dot txt and two dot txt okay i want to go back to this comment so all i have to do is i'll just click or i'll just copy this commit id right i'll clear screen i'll do a git revert and i'll just paste that commit id hit enter all right so let's go back to our terminal all right so now for doing this let us first see where we exactly are so we are on the feature one branch awesome so now we want to revert the changes right so for reverting the changes the first thing that you do is you see the log so right now the logs is that the last comment that was made on which the head is right now is this comment where we uh added these stashed changes see this caused a problem in my code and i want to revert this so i want to revert this comment so whatever changes i'm doing in this commit will be undone right now for doing that all i have to do is i'll copy this commit id okay and before just doing everything let me just do an ls and i can see that i have seven dot txt which i added in my stash changes right so what i'll do is i'll just do a git reward and i'll paste the comment id right so let me just take the comment id from over here done paste it here hit enter and now you can see it will say your seven dot txt will be deleted and we modified five dot txt remember right so my file which was modified five dot txt will also be reverted so these will be the changes which will be committed once i revert from this comment so i i'm like okay so i want to do this so i save it and now if i do an ls i can see that seven dot txt has been removed and my file also which was which i had modified has now been changed and you can see the changes over here so that two files have been changed one insertions and two deletions and this is it right this is this is what just happened and if and if now i do a git log you can basically just see that when i did git revert it basically committed a new thing on my feature one branch uh it committed a new file on my feature one branch with the message revert of committing staged stashed changes right and it says this revert commits 9a 60 90 so basically it undid the changes which i did in this particular commit now if you if you still want to go back to the comment and see what changes have actually been done what you can do is if i want to go to this commit all i have to do is just copy this commit id and now i'll type in git checkout and then the comment id okay so now i'm in the stashed commit right so now if i do an ls i can see that seven dot pxt is present right now uh what what i want to see is what what all things did we modify i think we modified five dot txt so let's do a cat on file.txt so i can see it says test file one two and here is my seven dot txt which i do if i do a cat it will say stash file check okay now what i'll do is i'll say kit git checkout feature one so it'll again return to the latest commit on the feature one branch so i'm returned now if i do an ls i can see that seven dot txt file is not there if i do a cat on five dot txt i can see that it has again returned to test file so my changes which i did over here that is a changed file in my commit of stash changes that i change the file content to test file one two and i changed i created a file called seven dot txt which i had stash file check i had reverted this commit and reverting means undoing the changes that you did in that comment right and it undid the changes uh i did in that comment so i don't no longer have seven dot txt which i created and i no longer have the contents of 5t dot txt to be the same as what was there in that particular comment okay but remember guys you still have that comment in your logs and if you want you can go to that comment and see what all things you want to fix right it's right here but the head of the uh the the feature branch has now changed to a new commit which basically has undead changes or undone changes of what was there over here okay sounds great so this was all about git revert all right moving forward the next command is get diff now git diff basically helps us in understanding what all has changed right what is the difference between two files or what is the difference between two commits what are the difference between two files you can all see that using the get diff command right for example if i come back here and i want to see the differences between what i did over here and what i did over here when i actually committed this dash so we can do that let us see how we can do that so i'll type in git diff okay get diff and then i'll type in this commit id which is on my head right now and this commit id which was uh which i basically reverted so i hit enter and it will tell me that what all did change from both these comments right so it say it says that you have modified five dot txt so there are two versions of five dot txt a slash five dot txt and b slash five dot txt right so the a uh file was deleted and the b file was added and it also shows the content which what content was changed and what content was added right so if if i am comparing the the the head with my previous commit it it says basically this file was changed and this file was added right and if i see over here it says that there was nothing before and then we added seven dot txt okay now if i do the same by reversing the order of the commits let's see what happens so what i'm gonna do now is i'm gonna say this is the commit which i want to check the difference with this comment so now you can see that it says that test file one two was removed and test file was added similarly seven dot txt was removed and null was added okay so basically this should be your newer commit and this should be your older commit and then it will tell the difference according to that right similarly if i uh want to do with this so i want to first check if everything is fine so let me do a get status okay so everything is committed on my fifa 1 branch what i'm gonna do is i'm gonna change something in four dot txt file okay so what i'll do is i'll do a get sorry i'll do a nano for dot dxd and let me change the file content to test file for diff i'll save it okay sorry so all right so let's say let's call this file as test file for diff i'll save it okay if the file is now saved i'll do an ls so now my four dot txt file has changed and i can see that and get status okay but i i want to know what exactly changed so what i can do is i can do a git diff with my head so head points to the committed uh version of my branch and i want to check uh what is happening currently right what is the current uh so current in my current directory i have not committed or have not staged the file for changes right my current directory is different from what is committed on the git file system so that is what i'm comparing right now i'm comparing my committed last my latest commit with what is there currently in my folder that is dot okay i hit enter and you can see it says that uh there is something which has changed in the four dot ext file so there was test file for clone before which now has been changed to test file for diff and this is exactly what i wanted to check so git diff is basically used to check the differences between two commits or two files okay and this is what exactly what we have checked right now awesome so let us come back to our slides so guys this brings us an end to all the common git commands that you could be using in your day-to-day life while you're using git right why is jenkins so important well we talked about it jenkins is a part of the continuous integration phase in devops it basically helps us to connect each and every part of the whole software development process and that's why it's so important now there are other there are a few other things also but let's first see what happens in the contents integration process so we have a developer who's developing some code and he pushes it to the version control system in the version control system there are different versions of the same code so version 4 which is the latest version and it is in the master branch gets pushed on to jenkins from where it heads to testing server so jenkins acts as a middleman where it takes the code and it sends it to a testing server where it gets tested now from here onwards if that if the code has been tested properly and if there are no issues it can go ahead for production but if there are any issues the there will be a feedback automatically sent to the developer so if there any issues the code in the code then the particular email will notify the developer and the jenkins manager also and if there are no issues then it will go to production now once the feedback goes to the developer the developer works on the code again and he pushes the new version that is the version five and the version five goes through the whole process again it goes through version control system and then goes to jenkins and then jenkins pushes it to testing server again now this time there are no issues so your testing server gives jenkinson okay and jenkins sends the version 5 into production server so it is a continuous cycle now the cycle will keep on repeating until there are no issues with the code or until whenever the you know people controlling the whole pipeline wish it to be so this is how your content integration will happen this is to give you guys an idea all right so jenkins is an open source tool so it's an open source tool that means you know no no one company or no one organization owns it but it is a very va it has a very vast community since because of its versatility a lot of people use it and it has a very wide range of supportability for a lot of different plugins and that's what that's what makes it so popular jenkins it's like it's a little bit complicated to get into not for everyone you can get into it but once you know about jenkins you can make good use of it it's like it could be the most powerful tool out there like compared to any other devops tools jenkins could be the most powerful tool but obviously it's not very it doesn't have a very user friendly interface if you had to use some other tool which had better user interface you go for bamboo or if you go for team city those guys have better interface but they're paid software's so jenkins is open source it's free and it has a much bigger community so jenkins is better and obviously jenkins has the best supportability for any tool like not any tool but most tools available in the market and that's why a lot of people use jenkins also all right so if you look at over here this could be a pipeline where you have your version control system let me just point that out so you have your version control system which stores the code with and once the code once the latest code has been pushed to the version control system it gives it to the build tools now the build tools will basically build the code in version control system so building basically means that you know once you written your code it's not the only thing that needs to be there for the application to be executed you need some resources you need some dependencies you need some extra libraries right those libraries those functions those dependencies they will get you know they and the code which is part of it they all will be combined into one single file called an artifact and that artifact is basically a dot exe file of the application so that artifact is the one that will be tested that is artifact is the one that will be deployed so that is uh a part building is a part of your devops and then you have a binary repository which basically will store all those different versions of artifacts all right and once it's stored it will test it and once it's tested it it will send it for deployment so as you can see there's something called containers so the concept of containers comes in when during deployment because when you deploy you will deploy your application in multiple containers now to get into that you guys will have to watch the docker video so go ahead and watch the docker video to understand more about the containers but just understand it's for deployment purposes all right so there are multiple tools involved in this whole pipeline and all of it is being controlled by jenkins your continuous integration master is the one that controls everything over here and that's what's important to know here also okay so that was the pipeline now let's move on let's see the jenkins architecture now jenkins has its architecture as in you will not have one jenkins server you will have rather a multiple set or you will have set of multiple jenkins that will be working together you will have a master jenkins server you'll have slave you'll have slave one jenkins server you'll have slave two jenkins server and basically all of these servers will you know um will work with each other to uh execute multiple build jobs now what build jobs are they're basically tasks so whenever you want to execute a particular task in jenkins you create a build job and you will execute it now you can you know set your own settings whether you want master to be the only one to execute particular type of build jobs or you want this whole setup to be in such a way that the build jobs will only be executed in those servers which are free so if you have slave one which is not free but slave two which is free and master is also busy then the build job will go to only slave two but if you set it in such a way that it has to wait for slave 1 for it to finish all of its previous build jobs and it doesn't it should not go to slave 2 at all then it will wait for all the jobs to finish and only then go to slave 1 even though slave 2 was free but that's again according to the criteria that you will set in jenkins right just understand in jenkins architecture you have a master server and you have slaves and this master is important for controlling the sales okay so the slaves job is only to basically you know execute the build jobs it does not do anything else all right so that's the jenkins architecture now guys finally let's move on to jenkins installation okay so to work with jenkins i'm going to be using aws instances and i recommend you guys use aws instances too but if you already have linux and you know if you determine to use the linux on your system you can go ahead and use that also this is that you know when you're practicing it's better to practice on instances all right so i'm going to go to my aws console over here and let me head to ohio go to ec2 okay so as you guys can see i already have jenkins master and jenkins slave so we'll basically build an architecture we'll connect both of these two and we will run a ci cd job so let me first open jenkins and install jenkins master and install jenkins on so i will do that by okay so i'm going to use putty to open it up let me try that again okay now i have my uh ubuntu server open so i'll just get root access sudo su su and uh then we'll update this instance and get update okay now that it's updated our next step will basically be to go to this location so you guys can go to package.jenkins.io slash deviant uh hyphen stable so once you reach over here you guys can look at the packages given over here the first package that is given over here just copy it right click it click on copy link address come back to your instance and type in wget and paste the link address so this will basically install that package of jenkins all right while we are waiting for this let me just tell you about you know next step so in the next step is basically once you've downloaded the dot deb file will basically be extracting it and installing it so we'll be using the sudo apt uh install command and dot slash jenkins triple two dot three dot all yeah all dot dv ub okay it's almost done okay so if i do an ls i can see the file let me just install it sudo apt effects you can install dot slash jenkins okay so i'll wait for it to get installed now this prefix is included just in case something goes wrong just a quick info guys intelpad provides devops online training validated and certified by nasscom future skills and ibm the course link is given in the description below now let's continue with the session all right guys while this is happening okay it's it's always done as i said maybe it got scared and that's where it finished the process early all right so now we have jenkins installed here okay so let me just do a system ctl start jenkins okay so now i have started jenkins so once i have jenkins running on my instance what i can do is if i want to launch the console the web console so i'll just go to my a to this instance again get my ip address and paste it in a new tab and type in 8080 now for those people who are working from their own systems you can type in localhost instead of the ip address but do write colon 88 and go to this particular address okay so first it will ask you to unlock jenkins it will ask you for an initial admin password you can do that you can you can get that password by copying this address so it's basically located in this file and we will just scat this particular file so let me just copy this address come back here cat and the address so enter and we have our password just copy it okay come back paste it here and click on continue okay so i would recommend you guys for you guys to click on install suggested plugins because you know if you have a suggested plugins it's much easier for beginners all right this might take a little bit well a little bit of time let me just close this we don't need that anymore and we have a slave over here while this loads it up i'll tell you guys about the slave so in the slave guys so in slave you don't need to install anything other than java right so you just need java in your slave so let's just install java in our slave i'll copy this and i'll open another [Music] putty we'll change its color so it's differentiable and we're gonna open it up yes okay so this is the sleep and on the slave you guys are supposed to download basically java open jdk open jdk 8 jdk all right sudo apt get install open jdk all right let me just try this again guys not after it's just tapped all right so let me just open up commands i've already written it all right it's not able to get it over here um what seems to okay yeah so let me just update it and get update so we need to update our instance all right so once we update it we will install java meanwhile yeah so this is finishing but let's finish one task and then we'll move on all right so now let's install java and we can install that over here also we'll install java here also which we forgot to do that is this is a master all right it's already installed that means i did so once we install java we can move on to setting up jenkins just a quick info guys test your knowledge of jenkins by answering this question which of the following is the useful plugins in jenkin a maven 2 project b amazon ec2 c html publisher the all of the above comment your answer in the comment section below subscribe to intellipack to know the right answer now let's continue with the session all right so we're almost done installing java here it's 98 okay i might have to close this once it's done all right so while it's doing is 98 we don't have to do anything more so we know it java's installed you guys can go ahead and type in your username i'm going to choose ram that's my name and type in a password i'm not going to tell you guys what the password is gmail.com okay so obviously enter your you know proper email id so that you get the notifications properly sorry for administration books so let's save and continue and if you guys want to change the jenkins url you can do so over here but i suggest you guys leave it be all right so let's click on save and finish all right so we can start using jenkins so guys we are finished with our jenkins installation process that brings us to our next step that is setting up a ci cd pipeline so when i talk to you guys about a software development pipeline what i meant was you know the phases to have all the phases now what we will do is we will basically be doing a very basic version of a proper software development pipeline okay so first what we're going to do is we're going to connect our jenkins master to a jenkins slave to do that click on manage jenkins once you've clicked on that click on configure global security and over here scroll down scroll down and on in agents under agents click on random all right so for tcp portfolio inbound agents we click it on random and then you guys can click on save so we configured the tcp setting now we will go ahead and add a new node so a new node is basically you know a new slave so we clicked on manage nodes we are over here so now you guys can go ahead and click on new node and that's how we will add a new slave so i'm gonna write here slave and let me just add one and click on permanent agent and then click on ok all right so over here we have to enter a few details so launch agent uh so the first thing we need to enter is remote root directory so i'm gonna add here home ubuntu and jenkins let me just copy this because we need to paste it in custom work directory path also okay and finally launch method leave it be a launch agent by connecting to it to the master that's good enough all right so once you're done writing these we can click on save and we can see that you know in our nodes we have master and slave so go ahead and click on slave one all right so once you click on slave one uh it will give you an agent.jar so what we are supposed to do now is we are supposed to transfer our agent or jar into the slave file because then we have to run this command all right so to do that we first have to download it so i already have one downloaded let me just delete that so it doesn't give me an error all right so i've already deleted it so i'm going to go ahead and click on agent.jar it will ask you where to download it i'm going to store it here okay so once i have it downloaded so our next step will be to transfer that file to our slave so how do we do that well there are two methods you can use filezilla or you guys can just use git bash there's a very easy way to do it just use git bash so we will head to our folder here so this is the folder where i have agent.jar and i will open git bash over here so get bashed guys is basically a terminal for using for gate purposes all right so i have git bash over here and i will type in the command so pay close attention to the command i'm using so the command i'm using is scp minus i space dot slash now here you're supposed to enter your key the name of the key that you're using for the instance because when you're transferring this file to the instance you need to access the instance and to need to access the instance you need to use the key so my key here is ram key [Music] then the name of the file that i want to transfer agent.jar is the name of the file and space ubuntu at i need to enter the ip address of my instance so the ip address is over here and copy it paste it okay now to mention where i want the file to be transferred so i want that file to be transferred to home slash ubuntu and that's it yes so now it's transferring the file okay so it has already transferred the file to check that we will go to our instance let's open it up and let's close this let's open this up if we do an ls we can see that agent.jar is now here all right guys we have transferred the agent.jar in our slave file we just have to copy this command now and run it okay it tells us that it's connected so if we refresh it tells us that projects tied to slave 1. so guys now we have successfully connected our slave 1 to our master so if we go back to nodes we can see slave 1 no longer has the cross sign here and master and slave are together so now we have created successfully created the jenkins architecture you can do this by you can also include a slave 2 if you guys want but since we won't be working with slave 2 i'm just going to leave it b now our next step is to basically create the ci cd pipeline so for that i will go back to the dashboard and in dashboard i'm going to click on create new jobs here i'm going to create a new job so that job will go through the whole pipeline and deploy my project so i will type the name of my job here so job or let me give it a good name so website job and i'm going to click on freestyle project that's the one i want to use and i'm going to go ahead and click on ok all right so now we have our job over here so we need to configure our job so there are a few things we need to configure over here guys let me first go to the source code management over here i'm going to select on git now we have to paste the repository url so basically you have to have the project in your github so i'm going to head to my my github github rtr sample project all right so let's have a project over here all right so this is the project i want to use so i'm just going to copy the url over here clone download copy the url and i'm going to paste it over here okay now the next thing i need to do is since it will be talking to the github i need to make sure that jenkins is able to talk to github so i'm going to go to my settings and in settings i will go to web hooks since jenkins will be talking to github through facebook and i'm going to add a web book over here and over here i need to add the payload url so where it needs to deliver so i'm just going to copy this ip address i'm going to paste it over here okay so i've pasted the ip address now the next thing i need to do is i need to go ahead and add git hub github web hook slash okay so that's it so i'm going to click on add webhook so it's going to check whether this is viable or not okay this hook has not been triggered yet so okay so it is working all right so if you go to webhooks all right so this tick mark means that last delivery was successful so that that means that jenkins is able to talk to my git here all right so now that we've done that we can go ahead and create uh configure our job all right so the description i'm gonna write this job will deploy my basic website and the website is over here if i click on code i can click on index.html and you guys can see the code it basically says welcome to visualization by run all right so now we have configured that all we have to do is the next thing we need to configure is we need to configure restrict where this project will be run so this is to show you guys how the architecture will work all right so here i'm going to enter slave 1 this is the one i want so [Music] mm-hmm just hold on a second guys let me go to manage jenkins go to manage nodes [Music] figure this change the name to just slave then we click on save right so okay we have to go through this process again let me just download this all right save yes and i want to transfer it over here again so i will have to get batch here okay so let me use the previous command that i used all right so we already have the command so we have to type it again but i will have to go ahead and delete the file that was here already let me just remove all of these okay so [Music] i pressed enter waiting for it to send the file now for ls again i can see agent.jar so let me just execute that command again okay it's connected so let me just refresh all right so no issues here let me try this once more all right so now it's working we have now restricted the project to be only run on the slave not on the master so we can see how the effect of the architecture happens okay all right so we have configured the restriction the get all right so the next thing we have to do is we need to yeah so we need to click check mark this github github github hook trigger so what this basically do is if i make any changes to this code it will automatically detect that change happening and once it detects that change happening it will basically you know do the whole build process again so it will trigger the whole build job again by itself now we need to add one more thing over here we need to add a bit step and we will add an execution shell all right so okay so here i'm going to write off command so basically guys will be running a basic website so we need apache for that so i need to install apache here we'll do that in a second so right now let me write the command so the command i'm gonna be writing is git clone and we're gonna copy the copy it paste this here and then i want this file the file i have to be transferred to the location so that apache can make it run all right so cp dot slash project slash sample project so let me change it to sample project then index dot html that's the name of my file and i want you to get to transfer to slash val slash www slash html okay so now i have my execution command over here so i will just save it okay so i've saved it but i need to go ahead and install apache on this so make sure that you don't exit this because it's a connection so just open another terminal over here i'll duplicate the session and over here i'm going to install apache sudo install apache 2 yes ok now we have apache 2 installed so now we just have to execute so this is my job i'll go back to the dashboard and we have to execute it so we have to reduce the bill so as you can see over here it is executed successfully that means if i go to the ip address of slave 2 paste it i can see that my website is working welcome to this live session by ram so guys we have successfully made our website run on the slave 2 and we created a very simple ci uh pipeline you know basically it's a build job what we did was we created a build job all right now let's do one more thing so to understand the whole automation process if you guys remember i did a automatic trigger whenever something changes in the git uh repository so let's go ahead and test that so i have my file over here and i will do another push with a little bit different code so let me just do that uh i have my file over here let me just get bash or let me just go do it directly it's much simpler so i'm gonna say [Music] you guys are awesome okay so now i'm going to commit the change uh commit changes so it comments over here now if a new commit happens whenever a new commit happens your jenkins will automatically detect it so if i refresh over here and you can see here that it's waiting for another build job to happen why because it detected a new change happening in the process all right so let's try this again and this seems to be an error update [Music] i have index.html it just hold on a second guys let me make that comment happen again so description revision let me just go back to the project okay so it's gonna give me the output and let's see the error that is giving us no credentials specified okay so that's the error it's giving us was commit message update was fatal destination sample project already exists is not an empty directory okay so destination path already exists is not an empty directory so we have to configure our project let me just go to build job configure it [Music] so let's just remove git here and [Music] save it so we remove the git clone and let's try this again so we're going for the third round and it's showing us that it's a success okay so now let's refresh this okay it's giving us the same output so we need to actually go back here configure i actually need to add sudo command let's try the get clone shouldn't give us an error this time paste it now put sudo cp now let's save this and let's go for a build now okay it's giving us an error let me just check this out all right so we have this let me save this and let's build it now okay so it's showing us success so guys it's working right just a quick info guys intelpad provides devops online training validated and certified by nasscom future skills and ibm the course link is given in the description below okay guys we've come to the end of this session i hope this session was helpful and informative for you if you have any queries leave a comment down below thanks for watching
Info
Channel: Intellipaat
Views: 2,987
Rating: 4.9266057 out of 5
Keywords: Devops Tools, GIT Tutorial For Beginners, Jenkins Tutorial for Beginners, top devops tools, devops tutorial, devops training, devops tutorial for beginners, learn devops, git, github, git tutorial, github tutorial, what is git, git tutorial for beginners, git commit, how to use git, learn git, git commands, what is github, jenkins tutorial, jenkins, jenkins pipeline tutorial, what is jenkins, jenkins pipeline, learn jenkins, jenkins training, Intellipaat
Id: -Ffuttr7znM
Channel Id: undefined
Length: 102min 15sec (6135 seconds)
Published: Tue May 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.