Jenkins Full Course | Jenkins Tutorial For Beginners | Jenkins Tutorial | Simplilearn

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
continuous integration is a major step in the devops life cycle it makes the development testing and deployment of applications easier and faster there are a number of continuous integration tools like bamboo apache gum jenkins buildbot and travis ci and among them jenkins is the most popular hi guys welcome to this complete jenkins tutorial by simply learn my name is sandeep and today we will be covering the most important continuous integration tool that is jenkins first we will understand what is devops and look at an introduction to devops then we will see how to install jenkins in windows after that we will learn what is jenkins look at a tutorial on jenkins and understand how jenkins pipeline works finally we have handpicked some of the most important jenkins questions that you might face in a devops interview let's first look at a small animated video to understand what is devops meet tim tim builds a robot in his lab a climate controlled and pollution-free environment once he's done he drops the robot off at his project partner mia's house mia takes it out to her backyard to ensure that the robot meets the requirements but here is where the problem arises the change in the environment causes the robot to malfunction mia is now really annoyed and she has a lot to correct and it seems to her as though tim didn't really do much this wall between them leaves a poor robot to bite the dust well what if we broke this wall tim and miana work together in a common space tim develops each block of functionality of the robot which is then immediately checked by mia both are now working simultaneously instead of waiting on the other to finish their task as and when a feature is ready for use they are put together to build the final product they develop a common mindset and share ideas to further speed up the process they use several tools which can automate every stage this means that the robot is now ready sooner with less iterations and manual work from an organization perspective tim would be the developer while mia the operations their union is the core of the devops approach devops has several stages and set of tools to automate each of these stages let's have a look at these tim first puts down a plan in terms of software this could mean deciding on the modules and the algorithms to use once he has the plan he now codes the plan with tools such as git tim has a repository for storing all the codes and their different versions this is called version control next this code is fetched and made executable this is the build stage tools such as gradle and maven will sort this out now before deployment the product is tested to catch any bugs the most popular tool automating testing is selenium once the products are tested mia must deploy it the deployed product is then continuously configured to the desired state ansible puppet and docker are some of the most common tools used that automate these stages now every product is continuously monitored in its working environment nagios is one such tool that automates this space and the feedback is fed back to the planning stage and finally we have the core of the devops lifecycle the integration stage tools such as jenkins is responsible for sending the code for build and test if the code passes the tests it's further sent for deployment this is called continuous integration let's now have a look at an organization that has adopted the devops approach which of the below sequence of steps would they follow to develop a software leave your answers in the comment section keep an eye out for the right answer on the comment section or our youtube community giants such as amazon netflix target xc and walmart have all adopted devops and seen a considerable increase in delivery and quality in 2014 an hour of downtime for netflix would cost it two hundred thousand dollars it became absolutely crucial that netflix prepared themselves for any sort of failure and so they took to the devops approach and implemented it in the most unique way they developed a tool called simeon army this tool created failures and automatically deployed them in an environment that did not affect the users the team would troubleshoot these failures and this gave them enough experience to deal with any degree of collapse with everything being automated and happening simultaneously organizations can now deliver at a much faster pace so considering the benefits of devops and its divergence from the traditional methods would devops be the future let us know what you think in the comment section below and with that we come to an end of our video i hope you are excited to learn more about devops and jenkins now we have matthew apexa and chidanan who will take you through this journey of learning jenkins in detail with that over to you matthew so this is matthew with simply learn and today we're going to go through and introduce you to devops we're going to go through a number of key elements today the first two will be reviewing models that you're already probably using for delivering solutions into your company and the most popular one is waterfall followed by agile then we'll look at devops and how devops differs from the two models and how it also borrows and leverages the best of those models we'll go through each of the phases that are used in typical devops delivery and then the tools used within those phases to really improve the efficiencies within devops finally we'll summarize the advantages that devops brings to you and your teams so let's go through waterfall so waterfall is a traditional delivery model that's been used for many decades for delivering solutions not just i.t solutions and digital solutions but even way before that it has its history that goes back to world war ii so waterfall is a model that is used to capture requirements and then cascade each key deliverable through a series of different stage gates that is used for building out the solution so let's take you through each of those stage gates the first that you may have done is requirements analysis and this is where you sit down with the actual client and you understand specifically what they actually do and what they're looking for in the software that you're going to build and then from that requirements analysis you'll build out a project planning so you have an understanding of what the level of work is needed to be able to be successful in delivering the solution after that you've got your plan then you start doing the development and that means that the programmers start coding out their solution they build out their applications to build out the websites and this can take weeks or even months to actually do all the work when you've done your coding and development then you send it to another group that does testing and they'll do full regression testing of your application against the systems and databases that integrate with your application you'll test it against the actual code you'll do manual testing you do ui testing and then after you've delivered the solution you go into maintenance mode which is just kind of making sure that the application keeps working there's any security risks that you address those security risks the problem you have though is that there are some challenges however that you have with the waterfall model the cascading deliveries and those complete and separated stage gates means that it's very difficult for any new requirements from the client to be integrated into the project so if a client comes back and if the project has been running for six months and they've gone hey we need to change something that means that we have to almost restart the whole project it's very expensive and it's very time consuming also if you spend weeks and months away from your client and you deliver a solution that they are only just going to see after you spend a lot of time working on it they could be pointing out things that are in the actual final application that they don't want or are not implemented correctly or lead to just general unhappiness the challenge you then have is if you want to add back in the client's feedback to restart the whole waterfall cycle again so the client will come back to you with a list of changes and then you go back and you have to start your programming and you have to then start your testing process again and just you're really adding in lots of additional time into the project so using waterfall model companies have soon come to realize that you know the clients just aren't able to get their feedback in quickly effectively it's very expensive to make changes once the teams have started working and the requirement in today's digital world is that solutions simply must be delivered faster and this has led for a specific change in agile and we start implementing the agile model so the agile model allows programmers to create prototypes and get those prototypes to the client with the requirements faster and the client is able to then send the requirements back to the programmer with feedback this allows us to create what we call a feedback loop where we're able to get information to the client and the client can get back to the development team much faster typically when we're actually going through this process we're looking at the engagement cycle being about two weeks and so it's much faster than the traditional waterfall approach and so we can look at each feedback loop as comprising of four key elements we have the planning where we actually sit down with the client and understand what they're looking for we then have coding and testing that is building out the code and the solution that is needed for the client and then we review with the client the changes that have happened but we do all this in a much tighter cycle that we call a sprint and that typically a sprint will last for about two weeks some companies run sprints every week some run every four weeks it's up to you as a team to decide how long you want to actually run a sprint but typically it's two weeks and so every two weeks the client is able to provide feedback into that loop and so you were able to move quickly through iterations and so if we get to the end of sprint two and the client says hey you know what we need to make a change you can make those changes quickly and effectively for sprint three what we have here is a breakdown of the ceremonies and the approach that you bring to agile so typically what will happen is that a product leader will build out a backlog of products and what we call a product backlog and this will be just a whole bunch of different features and they may be small features or bug fixes all the way up to large features that may actually span over multiple sprints but when you go through the sprint planning you want to actually break out the work that you're doing so the team has a mixture of small medium and large solutions that they can actually implement successfully into their sprint plan and then once you actually start running your sprint again it's a two-week activity you meet every single day to with the actual sprint team to ensure that everybody is staying on track and if there's any blockers that those blockers are being addressed effectively and immediately the goal at the end of the two weeks is to have a deliverable product that you can put in front of the customer and the customer can then do a review the key advantages you have of running a sprint with agile is that the client requirements are better understood because the client is really integrated into the scrum team they're there all the time and the product is delivered much faster than with a traditional waterfall model you're delivering features at the end of each sprint versus waiting weeks months or in some cases years for a waterfall project to be completed however there are also some distinct disadvantages the product itself really doesn't get tested in a production environment it's only been tested on the developer computers and it's really hard when you're actually running agile for the sprint team to actually build out a solution easily and effectively on their computers to mimic the production environment and the developers and the operations team are running in separate silos so you have your development team running their sprint and actually working to build out the features but then when they're done at the end of their sprint and they want to do a release they kind of fling it over the wall at the operations team and then it's the operations team job to actually install the software and make sure that the environment is running in a stable fashion that is really difficult to do when you have the two teams really not working together so here we have is a breakdown of that process with the developers submitting their work to the operations team for deployment and then the operations team may submit their work to the production service but what if there is an error what if there was a setup configuration error with the developers test environment that doesn't match the production environment there may be a dependency that isn't there there may be a link to an api that doesn't exist in production and so you have these challenges that the operations team are constantly faced with and their challenge is that they don't know how the code works so this is where devops really comes in and let's dig into how devops which is developers and operators working together is the key for successful continuous delivery so devops is as an evolution of the agile model the agile model really is great for gathering requirements and for developing and testing out your solutions and what we want to be able to do is kind of address that challenge and that gap between the ops team and the dev team and so with devops what we're doing is bringing together the operations team and the development team into a single team and they are able to then work more seamlessly together because they are integrated to be able to build out solutions that are being tested in a production-like environment so that when we actually deploy we know that the code itself will work the operations team is then able to focus on what they're really good at which is analyzing the production environment and being able to provide feedback to the developers on what is being successful so we're able to make adjustments in our code that it's based on data so let's step through the different phases of a devops team so typically you'll see that the devops team will actually have eight phases now this is somewhat similar to agile and what i'd like to point out at time is that again agile and devops are very closely related that agile and devops are closely related delivery models that you can use with devops it's really just extending that model with the key phases that we have here so let's step through each of these key phases so the first phase is planning and this is where we actually sit down with a business team and we go through and understand what their goals are the second stage is as you can imagine and this is where it's all very similar to agile is that the coders actually start coding but they typically they'll start using tools such as git which is a distributed version control software it makes it easier for developers to all be working on the same code base rather than bits of the code that is rather than them working on bits of the code that they are responsible for so the goal with using tools such as git is that each developer always has the current and latest version of the code you then use tools such as mavin and gradle as a way to consistently build out your environment and then we also use tools to actually automate our testing now what's interesting is when we use tools like selenium and junit is that we're moving into a world where our testing is scripted the same as our build environment and the same as using our get environment we can start scripting out these environments and so we actually have scripted production environments that we're moving towards jenkins is the integration phase that we use for our tools and another pointer here is that the tools that we're listing here these are all open source tools these are tools that any team can start using we want to have tools that control and manage the deployment of code into the production environments and then finally tools such as ansible and chef will actually operate and manage those production environments so that when code comes to them that that code is compliant with the production environment so that when the code is then deployed to the many different production servers that the expected results of those servers which is you want them to continue running is received and then finally you monitor the entire environment so you can actually zero in on spikes and issues that are relevant to either the code or changing consumer habits on the site so let's step through some of those tools that we have in the devops environment so here we have is a breakdown of the devops tools that we have and again one of the things i want to point out is that these tools are open source tools there are also many other tools this is just really a selection of some of the more popular tools that are being used but it's quite likely that you're already using some of these tools today you may already be using jenkins you may already be using git but some of the other tools really help you create a fully scriptable environment so that you can actually start scripting out your entire dev ops toolset this really helps when it comes to speeding up your delivery because the more you can actually script out of the work that you're doing the more effective you can be at running automation against those scripts and the more effective you can be at having a consistent experience so let's step through this devops process so we go through and we have a continuous delivery which is our plan code build and test environment so what happens if you want to make a release well the first thing you want to do is send out your files to the build environment and you want to be able to test the code that you've been created because we're scripting everything in our code from the actual unit testing being done to the all the way through to the production environment because we're testing all of that we can very quickly identify whether or not there are any defects within the code if there are defects we can send that code right back to the developer with a message saying what the defect is and the developer can then fix that with information that is real on the either the code or the production environment if however your code passes the scripting test it can then be deployed and once it's out to deployment you can then start monitoring that environment what this provides you is the opportunity to speed up your delivery so you go from the waterfall model which is weeks months or even years between releases to agile which is two weeks or four weeks depending on your sprint cadence to where you are today with devops where you can actually be doing multiple releases every single day so there are some significant advantages and there are companies out there that are really zeroing in on those advantages if we take any one of these companies such as google google any given day will actually process 50 to 100 new releases on their website through their devops teams in fact they have some great videos on youtube that you can find out on how their dev op teams work netflix is also a similar environment now what's interesting with netflix is that netflix have really fully embraced devops within their development team and so they have a devops team and netflix is a completely digital company so they have software on phones on smart tvs on computers and on websites interestingly though the devops team for netflix is only 70 people and when you consider that a third of all internet traffic on any given day is from netflix it's really a reflection on how effective devops can be when you can actually manage that entire business with just 70 people so there are some key advantages that devops has it's the actual time to create and deliver software is dramatically reduced particularly compared to waterfall complexity and maintenance is also reduced because you're automating and scripting out your entire environment you're improving the communication between all your teams so teams don't feel like they're in separate silos but that are actually working cohesively together and that there is continuous integration and continuous delivery so that your consumer your customer is constantly being delighted today we'll see how to install a very popular continuous integration tool called jenkins on windows first we'll see how to install java development kit jdk is one of the prerequisites you need in order to run gen kits then we set up the jtk path in the environment variable after that we'll see how to download and install jenkins on windows once that's complete we'll run jenkins on localhost 8080 which is the default port for running jenkins then we'll have a glance at the jenkins server interface and look at some of features present on jenkins finally we learn how to build and run a job in jenkins to download and install jtk simply type install jdk on google and click on the first link which is java s8 development kit 8. as you can see we get a list of downloads for jdk since i'm on a windows 64-bit system i've already installed jdk version for windows 64. before you install jdk you also need to accept the license agreement let me show you where my jdk has been installed first i go to my c drive program files under the java folder you find two more folders that's jdk and gre now let's set up the path in the environment variable go to system properties under the advanced tab select environment variables under system variables there are two more variables called java home and jre home java home contains the path for jdk i'll show you where it is go to jtk folder copy the path and paste it in the value section gre home contains the path for jre similarly go to the gre folder copy the path and paste it in the corresponding value one more thing you need to do is set up the bin folder location for jdk in path variables let's see where the bin folder location is here it is after setting up the location click ok to finish the setup now shall we check if java has been successfully installed for that go to the command prompt and type java hyphen version you can see our java is successfully installed and it's up and running the version we've installed is shown here now let's download jenkins on windows simply type download jenkins on google and click on the first link here we can see that jenkins provides two types of releases long term support release and weekly release as i'm interested in a more stable release so i will go for lts now when i scroll down i'll get an option for windows once i select that a stable installer starts to download you can see it says thank you for downloading windows table installer so now our jenkins has started downloading this might take a few seconds till then maybe you can catch up if you're left behind okay so the download is complete now let's go ahead and unzip downloaded jenkins file after the unzipping has been done we'll start the installation click on this folder click run next this is the default path where jenkins will be installed we don't need to change it so we can just go ahead with next install after this jenkins installation is successfully completed select finish yes that's all now that installation is complete let's go and explore jenkins go to your web browser and search localhost colon8080 you can see that it says welcome to jenkins so i have already created a username and password for jenkins i'll enter my credentials and that's all this is how the jenkins homepage and interface looks like and that's all signing in yes so that's the dashboard and this is how the jenkins homepage and interface looks like so if you're installing jenkins for the very first time it will ask you to install some recommended plugins i've already installed mine so i don't need to install them once again now there are a lot of things you can do in jenkins let me run you through a few of them there's some jobs that i've already created and run this is new item it allows you to create a new project so you can create a freestyle project a maven project a build pipeline etc then going back to the dashboard there is build history so this section shows you the status of your build here you can see what's the built name the time since the build is running and what's the status of your build there is another very important section called manage jenkins here you can configure your system you can configure global security credentials then there's some global tool configuration you can also download and manage your plugins here you can see there are four tabs where you have some updates you have some available plugins you have the plugins that you've already installed and then there's advanced plugin as well now let me show you how to create and run a job in jenkins so coming back to the dashboard let me select new item we can name our job here let me name the job as jenkins demo i will create a freestyle project so select that and click ok this might take a few seconds so when we have created that here we have a number of options that we can go ahead with you have your source code management building triggers building environment and then of course some post-built actions so that's about creating and running a job on jenkins let's give some description to our job so we have create the job we give description something like this is my first jenkins job so we will not use any source code management tool in the build section as you can see there is an option to execute windows batch command click on that and here you can give your command let's use the echo command i will write something like hello this is my first jenkins demo and then i'll also give the date and time parameters so that i can track on what date and time this job was built that's it so click apply and then save okay so this job is created now let's build it go to build now once you click it you can see a built history has been created click on that in the console output you can see the output of your very first jenkins job it says hello this is my first jenkins demo what you gave in the command box you can see that and you can also see the date date and time when this job was created so we've successfully created our first jenkins job hello this is matthew from simply learn and today we're going to deep dive into what jenkins is and how it improves your devops continuous integration environments so this is what we're going to be covering in this session we're going to cover what life is like before using jenkins and the issues that jenkins specifically addresses then we'll get into what jenkins is about and how it applies to continuous integration and the other continuous integration tools that you need in your devops team then specifically we'll deep dive into features of jenkins and the jenkins architecture and we'll give you a case study of a company that's using jenkins today to actually transform how their i.t organization is operating so let's talk a little bit about life before jenkins let's see this scenario i think it's something that maybe all of you can relate to as developers we all write code and we all submit that code into a code repository and we all keep working away writing our unit tests and hopefully we're running our unit tests but the problem is that the actual commits that actually gets sent to the code repository aren't consistent you as a developer may be based in india you may have another developer that's based in the philippines and you may have another team lead that's based in the uk and another development team that's based in north america so you're all working at different times and you have different amounts of code going into the code repository there's issues with the integration and you're kind of running into a situation that we like to call development hell where things just aren't working out and there's just lots of delays being added into the project and the bugs just keep mounting up the bottom line is the project is delayed and in the past what we would have to do is we'd have to wait until the entire software code was built and tested before we could even begin checking for errors and this just really kind of increase the amount of problems that you'd have in your project the actual process of delivering software was slow there was no way that you could actually iterate on your software and you just ended up with just a big headache with teams pointing fingers at each other and blaming each other so let's jump into jenkins and see what jenkins is and how it can address these problems so jenkins is a product that comes out of the concept of continuous integration that you may have heard of as power developers where you'd have two developers sitting next to each other coding against the same piece of information what they were able to do is to continuously develop their code and test their code and move on to new sections of code jenkins is a product that allows you to expand on that capacity to your entire team so you're able to submit your codes consistently into a source code environment so there are two ways in which you can do continuous delivery one is through 90 builds and one is through continuous so the approach that you can look at continuous delivery is modifying the legacy approach to building out solutions so what we used to do is we would wait for nightly builds and the way that our nightly builds would work and operate is that as co-developers we would all run and have a cut-off time at the end of the day and that was consistent around the world that we would put our codes into a single repository and at night all of that code would be run and operated and tested to see if there were any changes and a new build would be created that would be referred to as the nightly build with continuous integration we're able to go one step further we're able to not only commit our changes into our source code but we can actually do this continuously there's no need to race and have a team get all of their code in an arbitrary time you can actually do a continuous release because what you're doing is you're putting your tests and your verification services into the build environment so you're always running cycles to test against your code this is the power that jenkins provides in continuous integration so let's dig deeper into continuous integration so the concept of continuous integration is that as a developer you're able to pull from a repository the code that you're working on and then you'll be able to then at any time submit the code that you're working on into a continuous integration server and the goal of that continuous integration server is that it actually goes ahead and validates and passes any tests that a tester may have created now if on the continuous integration server a test isn't passed then that code gets sent back to the developer and the developer can then make the changes it allows the developer to actually do a couple of things it allows the developer not to break the build and we all don't want to break the builds that are being created but it also allows the developer not to actually have to run all the tests locally on their computer write tests particularly if you have a large number of tests can take up a lot of time so if you can push that service up to another environment like a continuous integration server it really improves the productivity of your developer what's also good is that if there are any code errors that have come up that may be beyond just the standard ci test so maybe there's a code the way that you write your code isn't consistent those errors can then be passed on easily from the tester back to the developer too the goal from doing all this testing is that you're able to release and deploy and your customer is able to get new code faster and when they get that code it simply just works so let's talk a little bit about some of the tools that you may have in your continuous integration environment so the cool thing with working with continuous integration tools is that they are all open source at least the ones that we have listed here are open source there are some that are private but typically you'll get started with open source tools and it gives you the opportunity to understand how you can accelerate your environment quickly so bamboo is a continuous integration tool that specifically runs multiple builds in parallel for faster compilation so if you have multiple versions of your software that runs on multiple platforms this is a tool that really allows you to get that up and running super fast so that your teams can actually test how those different builds would work for different environments and this has integration with and maven and other similar tools so one of the tools you're going to need is a tool that allows you to automate the software build test and release process and buildbot is that open source product for you again it's an open source tool so there's no license associated with this so you can actually go in and you can actually get the environment up and running and you can then test for and build your environment and create your releases very quickly so buildbots also written in python and it does support parallel execution jobs across multiple platforms if you're working specifically on java projects that need to be built and test then apache gump is the tool for you it makes all of those projects really easy it makes all the java projects easier for you to be able to test with api level and functionality level testing so one of the popular places to actually store code and create a versioning of your code is github and it's a service that's available on the web just recently acquired by microsoft if you are storing your projects in github then you'll be able to use travis continuous integration or travis ci and it's a tool designed specifically for hosted github projects and so finally we're covering jenkins and jenkins is a central tool for automation for all of your projects now when you're working with jenkins sometimes you'll find there's documentation that refers to a product called hudson hudson is actually the original version of the product that finally became jenkins and it was acquired by oracle when that acquisition happened the team behind um hudson was a little concerned about the direction that oracle may potentially go with hudson and so they created a hard fork of hudson that they renamed jenkins and jenkins has now become that open source project it is one of the most popular and continuously contributed projects that's available as open source so you're always getting new features being added to it it's a tool that really becomes the center for your ci environment so let's jump into some of those really great features that are available in jenkins so jenkins itself is really comprised of five key areas around easy installation easy configuration plugins extensibility and distribution so as i mentioned for the easy installation jenkins is a self-contained java program and that allows it to run on most popular operating systems including windows mac os and unix you even run it on linux it really isn't too bad to set up it used to be much harder than it is today the setup process has really improved the web interface makes it really easy for you to check for any errors in addition you have great built-in help one of the things that makes tools like jenkins really powerful for developers and continuous integration teams in your devops teams as a whole when you have plugins that you can then add in to extend the base functionality of the product jenkins has hundreds of plugins and you can go and visit the update center and see which other plugins that be good for your devops environment certainly check it out there's just lots of stuff out there in addition to the plug-in architecture jenkins is also extremely extensible the opportunity for you to be able to configure jenkins to fit in your environment is almost endless now it's really important to remember that you are extending jenkins not creating a custom version of jenkins and that's a great differentiation because the core foundation remains as the core jenkins product the extensibility can then be continued with newer releases of jenkins so you're always having the latest version of jenkins and your extensions mature with those core foundation the distribution and the nature of jenkins makes it really easy for you to be able to have it available across your entire network it really will become the center of your ci environment and it's certainly one of the easier tools and more effective tools for devops so let's jump into the standard jenkins pipeline so when you're doing development you start off and you're coding away on your computer the first thing you have to do when you're working in the jenkins pipeline is to actually commit your code now as a developer this is something that you're already doing or at least you should be doing you're committing your code to a git server um or to an svn server or a similar type of service so in this instance you'll be using jenkins as the place for you to commit your code jenkins will then create a build of your code and part of that build process is actually going through and running through tests and again as a developer you're already comfortable with running unit tests and writing those tests to validate your code but there may be additional tests that jenkins is running so for instance as a team you may have a standard set of tests for how you actually write out your code so that each team member can understand the code that's been written and those tests can also be included in the testing process within the jenkins environment assuming everything past the the tests you can then get everything placed in a stage and release ready environment within jenkins and finally again ready to deploy or deliver your code to a production environment jenkins is going to be the tool that helps you with your server environment to be able to deploy your code to the production environment and the result is that you're able to move from a developer to production code really quickly this whole process can be automated rather than having to wait for people to actually test your codes or go through a nightly build you're looking at being able to commit your code and go through this testing process and release process continuously as an example companies etsy will release up to 50 different versions of their website every single day so let's talk about the architecture within jenkins that allows you to be so effective at applying a continuous delivery devops environment so the server architecture really is broken up into two sections on the left hand side of the section you have the code the developers are doing and submitting that code to a source code repository and then from then jenkins is your continuous integration server and it will then pull any code that's been sent to the source code repository and will run tests against it it will use a build server such as maven to actually then build the code and every single stage that we have that jenkins manages there are constant tests so for instance if a build fails that feedback is sent right back to the developers so that they can then change their code so that the build environment can run effectively the final stage is to actually execute specific test scripts and these test groups can be written in selenium so it's probably good to mention here that both mavin and selenium are plugins that run in the jenkins environment so before we were talking about how jenkins can be extended with plugins mavin and selenium are just two very popular examples of how you can extend the jenkins environment the goal to go through this whole process again is an automated process is to get your code from the developer to the production server as quickly as possible have it fully tested and have no errors so it's probably important at this point to mention uh one piece of information around the jenkins environment that if you have different code builds that need to be managed and distributed this will require that you need to have multiple builds being managed jenkins itself doesn't allow for multiple files and builds to be executed on a single server you need to have a multiple server environment with running different versions of jenkins for that to be able to happen so let's talk a little bit about the master slave architecture within jenkins so what we have here is an overview of the master slave architecture within jenkins on the left hand side is the remote source code repository and that remote source code repository could be github or it could be team foundation services or the new azure devops code repository or it could be your own git repository the jenkins server acts as the master environment on the left hand side and that master environment can then push out to multiple other jenkins slave environments to distribute the workload so it allows you to run multiple builds and tests and production environments simultaneously across your entire architecture so jenkins slaves can be running the different build versions of the code for different operating systems and the server master is controlling how each of those builds operate so let's step into a quick story of a company that has used jenkins very successfully so here's a use case scenario over the last 10 or 15 years there has been a significant shift within the automotive industry where manufacturers have shifted from creating complex hardware to actually creating software we've seen that with companies such as tesla where they are creating software to manage their cars we see the same thing with companies such as general motors with their onstar program and ford just recently have rebranded themselves as a technology company rather than just a automotive company what this means though is that the software within these cars is becoming more complex and requires more testing to allow more capabilities enhancements to be added to the core software so bosch is a company that specifically ran into this problem and their challenge was that they wanted to be able to streamline the increasingly complex automotive software by adopting continuous integration and continuous delivery best practices with the goal of being able to delight and exceed the customer expectations of the end user so bosch has actually used cloudbees which is the enterprise jenkins environment so to be able to reduce the number of manual steps such as building deploying and testing bosch has introduced the use of cloud b's from jenkins and this is part of the enterprise jenkins platform it has significantly helped improve the efficiencies throughout the whole software development cycle from automation stability and transparency because jenkins becomes a self-auditing environment now the results have been tangible previously it took three days before a bill process could be done and now it's taken that same three-day process and reduced it to less than three hours that is significant large-scale deployments are now kept on track and have expert support and there is clear visibility and transparency across the whole operations through using the jenkins tools hello and welcome to continuous integration tutorial using jenkins my name is chidanand and i am with the simply learn team today let's get started with jenkins jenkins in my opinion is one of the most popular continuous integration servers of recent times what began as a hobby project by a developer working for sun microsystems way back in early or mid-2000s has gradually and eventually evolved into very very powerful and robust automation servers it has a wide adoption since it is released under mit license and is almost free to use jenkins has a vast developer community that supports it by writing all kinds of plugins plugins is the heart and soul of jenkins because using plugins one can connect jenkins to anything and everything under the sun with that introduction let's get into what all will be covered as a part of this tutorial i will get into some of the prerequisites required for installing jenkins post which i will go ahead and install jenkins on a windows box there are a few first time configuration that needs to be done and i will be covering those as well so once i have jenkins installed and configured properly i will get into the user administrative part i create few users and i will use some plugins for setting up various kinds of access permissions for these users i will also put in some freestyle jobs freestyle job is nothing but a very very simple job and i will also show you the powerfulness of jenkins by scheduling this particular job to run based upon time schedule i will also connect jenkins with github github is our source code where source code repository where i've got some repositories put up there so using jenkins i will connect to github pull up a repository that is existing on github onto the jenkins box and run few commands to build this particular repository that is pull from github sending out emails is a very very important configurations of jenkins or any other continuous integration server for that matter whenever there is any notifications that has to be sent out as a part of either a build going bad or built being good or built being propagated to some environment and all these scenarios you would need the contains integration servers to be sending out notifications so i will get into a little bit details of how to configure jenkins for sending out emails i will also get into a scenario where i will have a web application a maven based java web application which will be pulled from a github repository and i will deploy it onto a tomcat server the tomcat server will be locally running on my system eventually i will get into one other very very important topic which is the master slave configuration it's a very very important and pretty interesting topic where distributed builds is achieved using a master slave configuration so i will bring up a slave i will connect the slave with the master and i will also put in a job and kind of delegate that particular job to the slave configuration finally i will let you know how to use some plugins to backup your jenkins so jenkins has got a lot of useful information set up on it in terms of the build environments in terms of workspace all this can be very very easily backed up using a plugin so this is what i'm going to be covering as a part of this tutorial jenkins is a web application that is written in java and there are various ways in which you can use and install jenkins i have listed popular three mechanisms in which jenkins is usually installed on in any system the topmost one is as a windows or a linux based services so if at all you have windows like the way i have and i'm going to use this mechanism for this demo so i would download a msi installer that is specific to jenkins and install this service so whenever i install as a service it goes ahead and nicely installs all that is required for my jenkins and i have a service that can be started or stopped based upon my need any flavor of linux as well one other way of running jenkins is downloading this generic war file and as long as you have jdk installed you can launch this war file by the command opening up a command prompt or shell prompt referral on linux box specifying java hyphen jar and the name of this war file it typically brings up your web application and you know you can continue with your installation the only thing being if at all you want to stop using jenkins you just go ahead and close this prompt you either do a ctrl c and then bring down this prompt and your jenkins server would be down other older versions of jenkins were run popularly using this way in which you already have a java based web server running up and running so you kind of drop in this war file into the root folder or the httpd root folder of your web server so jenkins would explode and kind of bring up your application all user credentials or user administration is all taken care of by the apache or the tomcat server or the web server on which jenkins is running this wasn't a very older way of running but still some people use it because if they don't want to maintain two servers if they already have a java web server which it's being nicely maintained and backed up jenkins can run attached to it all right so either ways it doesn't matter however you're going to bring up your jenkins instance the way we're going to operate jenkins is all going to be very very same or similar one with the subtle changes in terms of user administration if at all you're launching it through any other web server which will take care of the user administration otherwise all the commands or all the configuration or the way in which i'm going to run this demo it is going to be same across any of these installations all right so the prerequisites for running jenkins as i mentioned earlier jenkins is nothing but a simple web application that is written in java so all that it needs is java preferably jdk 1.7 or 1.8 2gb ram is the recommended ram for running jenkins and also like any other open source tool sets when you install jdk ensure that you set in the environment variable java home to point to the right directory this is something very specific to jdk but for any other open source tools that you've installed there is always a preferred environment variable that you got to set in which is specific to that particular tool that you're going to use this is a generic thing that is there for you know for any other open source projects because the way open source projects discover themselves is using this environment variables so as a general practice or a good practice always set these environment variables accordingly so i already have jdk 1.8 installed on my system but in case you do not what i would recommend is just navigate on your browser to the oracle home page and just type in or search for install jdk 1.8 and navigate to the oracle home page you'll have to accept the license agreement and there are a bunch of installers that is okay that you can pick up based upon the operating system on which you're running so i have this windows 64 installer that is already installed and running on my system so i will not get into the details of downloading this or installing it let me show you once i install this what i've done with regard to my path so if you get into this environment variables all right so i have just set in a java home variable if you see this column program files java jdk 1.8 this is where my my java is located c program files c program files java okay so this is the home directory of my jdk so that is what i have been i have set it up here in my environment variable so if you see here this is my java home alright one other thing to do is ensure that in case you want to run java or java c from a command prompt ensure that you also add that path into this path variable so if you see this somewhere i will see yes there you go c colon program files java jdk 1.8 pin so with these two i'll ensure that my java installation is nice and you know good enough so to check that to double check that or to verify that let me just open up a simple command prompt and if i type in java iphone version all right and java c iphone version so the compiler is on the path java is on the path and if at all i do this the environment variable specific to my java is installed correctly so i am good to go ahead with my jenkins installation now that i have my prerequisites all set for installing jenkins let me just go ahead and download jenkins so let me open up a browser and say download jenkins all right lts is nothing but the long term support these are all stable versions weeklies i would not recommend that you try these unless until you have a real need for that long term support is good enough and as i mentioned there are so many flavors of jenkins there is available for download you also have a docker container wherein you know you can launch jenkins as a container but i'll not get into details of that in this tutorial all right so what i want is yes this is the war file which is generic war file that i was talking to you earlier and this is the windows msi installer so go ahead and download this msi installer i already have that downloaded so let me just open that up all right so this is my downloaded jenkins instance or rather installer this is a pretty maybe a few months old but this is good enough for me before you start jenkins installation just be aware of one fact that there is a variable called jenkins home this is where jenkins would store all this configuration data jobs project workspace and all that specific to jenkins so by default if at all you don't set this to any particular directory if at all you install an msi installer all your installation gets into sql and program files 86 and jenkins folder if at all you run a war file depending upon the user id with which you're running your war file the jenkins folder there's a dot jenkins folder that gets created inside the user home directory so in case you have any need wherein you want to back up your jenkins or you want jenkins installations to get into some specific directories go ahead and set this jenkins home variable accordingly before you even begin your installation for now i don't need to do any of these things so i've already downloaded the installer let me just go ahead with the default installation all right so this is my jenkins msi installer i would just i don't want to make any changes into the jenkins configuration c colon program files is good for me yeah this is where all my destination folder and all the configuration specific to it goes i'm happy with this i don't want to change this i would just say go ahead and click installation okay so what typically happens once the jenkins installation gets through is it'll start installing itself and there are some small checks that needs to be done so and by default jenkins launches on the port 8080 so let me just open up localhost 8080. there's a small checking that will be done as a part of the installation process wherein i need to type in the hash key all right so there's a very very simple hash key that gets stored out here so i'll have to just copy this path if i told you you're running as a war file you would see that in your logs all right so this is a simple hash key that gets created every time when you do a jenkins station so as a part of the installation it just asks you to do this so if that is not great it will crib about it but this looks good so it's going ahead all right one important part during the installation so you would need to install some recommended plugins what happens is the plugins are all related to each other so it's like the typical rpm kind of a problem where you try to install some plugin and it's got a dependency which is not installed and you get into all those issues in order to get rid of that what jenkins recommends there's a bunch of plugins that is already recommended so just go ahead and blindly click that install recommended plugin so if you see there is a whole lot of plugins which are bare essential plugins that is required for jenkins in order to run properly so jenkins as a part of the installation would get all these plugins and then install it for you this is a good combination to kind of begin with and mind you at this moment jenkins needs lots of bandwidth in terms of network so in case your your network is not so good few of these plugins would kind of fail and these plugins are all you know on available on openly or or mirrored sites and sometimes some of them may be down so do not worry in case some of these plugins kind of fail to install you'll get an option to kind of retry installing them but just ensure that you know at least most or 90 95 of all these plugins are installed without any problems let me pause the video here for a minute and then get back once all these plugins are installed my plugin installation is all good there was no failures in any of my plugins so after that i get to create this first admin user again this is one important point that you got to remember in given any username and password but ensure that you kind of remember that because it's very hard to get back your username and password in case you forget it alright so i'm going to create a very very simple username and password something that i can remember i will that's my name and um an email id is kind of optional but it doesn't allow me to go ahead in case i don't so i just given an admin and i got a password i've got i remember my password this is my full name all right i say save and finish all right that kind of completed my jenkins installation it was not that tough was it now that i have my jenkins installed correctly let me quickly walk you through some bare minimal configurations that is required these are kind of a first time configuration that is required so and also let me warn you the ui is little hard for many people to wrap their head around it specifically the windows guys but if at all you're a java guy you know how painful it is to write ui in java you will kind of appreciate you know all the effort that has gone into the ui bottom line you are a little hard to you know wrap your head around it but once you start using it possibly you'll start liking it all right so let me get into something called as manage and cans this can be viewed like a main menu for all jenkins configuration so i'll get into some of those important ones something called as configure system configure system this is where you kind of put in the configuration for your complete jenkins instance few things to kind of look out for this is a home directory this is a java home where all the configurations all the workspace anything and everything regarding jenkins is stored out here system message you want to put in some message on the system you just type in whatever you want and it's probably show up somewhere up here on the menu number of executors very very important configuration this just lets jenkin know at any point in time how many jobs or how many threads can be run you can kind of visualize it like a thread that can be run on this particular instance as a thumb rule if at all you're on a single core system number of executors two should be good enough in case at any point in time if there are multiple jobs that kind of get triggered the same time in case the number of executors are less compared to the number of jobs that have there to woken up no need to panic because they will all get queued up and eventually jenkins will get to running those jobs just bear in mind that whenever a new job kind of you know gets triggered the cpu usage and the memory usage in terms of the disk right is very high on the jenkins instance so that's something that you got to kind of keep in mind all right but number of executors 2 for my system is kind of good label for my jenkins i don't want any of these things usage how do you want to use your jenkins this is good for me because i only have a primary server that is running so i want to use this node as much as possible quite pretty each of these options have got some pair minimal help kind of a thing that is that is out here by clicking on these question marks you will get to know as to what are these particular configurations all right so this all look good what i want to show you here is there's something regarding the docker timestamps git plugin svn email notifications i don't want that what i want the yes i want this smtp server configuration remember i mentioned earlier that i would want jenkins to be sending out some emails and what i've done here is i've just configured the smtp details of my personal email id in case you're in a in organization you would have some sort of an email id that is set up for a jenkins server so you can specify the smtp server details of your company so that you know you can authorize jenkins to kind of send out emails but in case you want to try it out like me i have configured my personal email id which is on my gmail for sending out notifications so the smtp server would be smtp.gmail.com i'm using the smtp authentication i have provided my email id and my password i'm using the smtp port which is 465 and i'm you know reply to address is the same as mine i can just send out an email and see if at all this configuration works again gmail would not allow you to allow anybody to send out notifications on your behalf so you'll have to lower the security level of your gmail id so that you can allow a programmatically somebody to send out email notifications on your behalf so i've done already that i'm just trying to see if i can send a test email with the configuration that i've set in yes all right so the email configuration looks good so this is how you configure your uh you know your gmail account in case you want to do that if not put in your organization smtp server details which are for the valid username and password and it should all be set all right so no other configurations that i'm going to change here all of these look good all right so i come back to managing kens okay one other thing that i want to kind of go over is the global tool configuration imagine this scenario look at it this way jenkins is a is a continuous integration server it doesn't know what kind of a code base it's going to pull in what kind of a tool set that is required or what is the code that is going to pull in and how is it going to build so you would have to put in all the tools that is required for building the appropriate kind of code that you're going to pull in from you know your source code repositories so just to give you an example in case your source code is a java source code and assuming that you know because in this demo this is my laptop and i've put in all the configurations jdk everything on my laptop because i'm a developer i'm working on the laptop but my continuous integration server would be you know a separate server without anything being installed on it so in case i want jenkins to you know run a java code i would need to install jdk on it i need to specify the jdk location of this out here this way okay since i already have the jdk installed and i've already put in the java home directory or rather at the environment variable correctly i don't need to do it git if at all i want the jenkins server to use git git is a you know command bash or the command prompt for for running git and connecting to any other git server so you would need git to be you know installed on that particular system and set the path accordingly gradle and maven if at all you have some mavens as well you want to do this any other tool that you're going to install on your system which is your continuous integration server you will have to come in here and configure something in case you don't configure it when jenkins runs it will not be able to find these tools for building your task and it'll crib about it that's good i don't want to save anything manage jenkins let me see what else is required yes configure global security all right the security is enabled and if you see by default it's the security access control is set to jenkins own user database so what does this mean you know jenkins by default it uses file system where it stores all the user names which hashes up these user names and kind of stores them so as of now it jenkins is configured to use its own database assuming that you are running in an organization you would probably want to have a you know some sort of an ad or an ldap server using which you would want to control access to your jenkins repository rather jenkins tool so you would specify your ldap server details the root dn password or the manager dn and the manager password and all these details in case you want to connect your jenkins instance with your ldap or ad or any of the authentication servers that you have in your organization but for now since i don't have any of these things i'm going to use this own database that's good enough all right so i will set up some authorization methods and stuff like that once i put in few jobs so for now let me not get into any of these details of this just be aware that jenkins can be connected for authorization to an ldap server or you can have jenkins managing its own servers which is happening as of now so i'm going to save all this stuff that's good for me so enough of all these configurations let me put in a very very simple job all right so job new item you know little difficult to kind of figure out but then that's the new item so i'll just say you know first job this is good for me i just give a name for my job i would say it's a freestyle project that's good enough for me i don't want to choose any of that so unless until you choose any of this this particular button would not become active so choose the freestyle project and say ok at a very high level you would see general source code management build triggers build environment build and post build in case you install more and more plugins you will see a lot more options but for now this is what you would see so what am i doing at the moment i'm just putting up a very very simple job and the job could be anything and everything so i don't want to put in a very complicated job for now for the demo let me just put in a very very simple job i'll give a description this is an optional thing this is my first jenkins job all right i don't want to choose any of these again there are some helps available here i don't want to choose any of this i don't want to connect it into any source code for now i don't want any triggers for now i'll come back to this in a while build the environment i don't want any build environment as a part of this build step you know i just want to you know run few things so that i kind of complete this particular job so since i'm on a windows box i would say execute windows batch command all right so what do you want to do i would let me just echo something echo uh hello this is my first jenkins job and possibly i would want the date and the timestamp pertaining to the job i mean the date and time in which this job was run all right very very simple command that says you know this is my first job it just puts out something along with the date and the time all right i don't want to do anything else i want to keep this job as simple as this so let me save this job all right so once i save this job you know the job names comes up here and then i need to build this job and you would see some build stray out here nothing is there as of now because i've just put in a job i have not run it yet all right so let me try to build it now you see a build number you will see a date and a time stamp so if i click on this you will see a console output if i go here okay as simple as that and where is all the job details that is getting into if you see this if i navigate to this particular directory all right so this is the directory what i was mentioning earlier regarding jenkins home so all the job related stuff that is specific to this particular jenkins installation is all here all the plugins that is installed the details of each of those plugins can be found here all right so the workspace is where all the jobs that i've created whichever i'm running would be wrong there will be individual folders specific to the jobs that has been put up here all right so one job one quick run that's what it looks like pretty simple okay let me do one thing let me put up a second job i would say second job i would say freestyle project all right this is my second job i just want to demonstrate the powerfulness of the automation server and how simple it is to automate a job that is put up on jenkins which will be triggered automatically remember what i said earlier about jenkins because at the core of jenkins is a very very powerful automation server all right so what i'm going to do i will just keep everything else the same i'm going to put in the build script pretty much similar to second job that gets triggered automatically every minute all right let me do that percentage date and i'll put in the time all right so i just put in another job called second job and it pretty much does the same thing as what i was doing earlier in terms of printing the date and the time but this time i'm just going to demonstrate the powerfulness of the automation server that is there if you see here there's a build trigger so a build can be triggered using various triggers that is there so we'll get into this github triggering or hook or a web hook kind of a triggering later on but for now what i want to do i want to ensure that this job that i'm gonna put in would be automatically triggered on its own let's say every minute i want this job to be run on its own so build periodically is my setting if you see here there's a bunch of help that is available for me so for those of you who have written cron jobs on linux boxes you'll find it very very simple but for others don't panic let me just put up a very very simple regular expression for scheduling this job every minute all right so that's one two three four five all right come up come up come up all right so five stars is all that i'm going to put in and jenkins got a little worried and is asking me do you really mean every minute oh yeah i want to do this every minute let me save this and how do i check whether it gets triggered every minute or not i just don't do anything i'll just wait for a minute and if at all everything goes well jenkins would automatically trigger my second job in a minutes time from now this time around i'm not going to trigger anything look there you see it's automatically got trigger if i go in here yep second job that gets triggered automatically you know it was triggered at 42 1642 which is 442 my time that looks good and if everything goes well every one minute onwards this jog would be automatically triggered now that i have my jenkins up and running a few jobs that has been put up here on my jenkins instance i would need a way of controlling access to my jenkins server this is wherein i would use a plugin called role based access plugin and create few rules the rules are something like a global rule and a project rule project specific growth i can have different roles and i can have users who have signed up or the users who might create kind of assigned to these roles so that each of these users fall into some category this is my way of kind of controlling access to my jenkins instance and ensuring that people don't do something unwarranted all right so first things first let me go ahead and install a plugin for doing that so i get into manage jenkins and manage plugin a little bit of a confusing screen in my opinion there's updates available installed in advance as of now we don't have the role based plugin so let me go to available it'll take some time for it to get refreshed all right now these are the available plugins these are the install plugins all right so let me come back to available and i would want to search for my role-based access plugin so i would just search for role and hit enter okay role-based authorization strategy enables user authorization using a role-based strategy roles can be defined globally or for particular jobs or nodes and stuff like that so exactly this is the plugin that i want i would want to install it without a restart right looks good so far yes go back to the top of the page yes remember jenkins is running on a java using a java instance so typically many things would work the same way unless and until you want to restart jenkins once in a while but as a good practice whenever you do some sort of a big installations or big patches on your jenkins instance just ensure that you kind of restart it otherwise there would be a difference in terms of what is installed on the system and what is there on the file system you will need to flush out few of those settings later on but for now these are all very small plugins so this would run without any problems but otherwise if at all there are some plugins which would need a restart you know kindly go and restart your jenkins instance but for now i don't need that it looks good i've installed the plugin so where do i see my plugin i installed the plugin that is specific to the user control or the access control so let me go into yes global security and uh i would see this role-based strategy showing up now all right so this comes in because of my installation of my role-based plugin so this is what i would want to enable because i already have my own database set up and for the authorization part in the sense that who can do what i'm going to install i mean i've already installed a role based strategy uh plugin and i'm going to enable that strategy all right i would say save okay now i've installed the role based access plugin i would need to just set it up and check that you know i would go ahead and create some roles and ensure that i assign users as per these roles all right so let me go to manage jenkins configure all right let me see where is this configure configure global security is that where i create my roles nope not here yes manage and assign roles okay again you would see these options only after you install these plugins so for now i i've just enabled the plugin i have enabled role-based access control and i would go ahead and create some rules for this particular jenkins instance so i would say first manage rules so i would need to create some roles here and the rules are at a very high level these are global rules and there are some project rules and there are some slave rules i'll not get into details of all of these at a very very high level which is a global role let me just create a role a role can be kind of visualized like a group so i would create a role called developer typically the jenkins instance or the ca instance are kind of owned up or controlled by qa guys so qr guys would need to provide some sort of you know limited access to developers so that's why i'm creating a role called developer and i'm adding this role at a global role level so i would say add this here and you would see this developer role that is there and each of these options if you hover over it you would see some sort of a help on what what are these uh you know permissions specific to so what i want is like you know it sounds a little you know different but i would want to give very very little permissions for the developer so from an administration perspective i would just want him to have a read kind of a role credentials again i would just want to view kind of a rule i don't want him to create any agents and all that stuff that looks good for me for a job i would want him to just possibly read i don't want him to build i don't want him to cancel any jobs i don't want him to configure any job i don't even want him to create any job i would just want him to read few things i would not give him possibly a role to the workspace as well i mean i don't want him to have access to the workspace i would just want him to read a job check you know have read only access to the job run no i don't want him to give him any any particular access which will allow him to run any jobs view configure yeah possibly create yeah delete i don't want to read yes definitely and this is the specific role so what i'm doing i'm just creating a global role called developer and i'm giving him very very limited roles in the sense that i don't want this developer to be able to run any agents nor create jobs or build jobs or cancel jobs or configure jobs at the max i just want him to read a job that is already put up there okay so i would save now i created a role i still don't have any users that is there on the system so let me go ahead and create some user on the system that's not here house configure manager cans manage users okay let me create a new user i would call this user as yeah developer one sounds good some password some password that i can remember okay his name is developer1 d at d.com or something like that okay so this is the admin with with which i kind of configured or brought up the system and developer one is a user that i have configured so still have not set any rules for this particular user yet so i would go to manage and gains i would say manage and assign roles i would say assign roles okay so if you see what i'm going to do now is assign a role that is specific to that particular i will find the particular user and assign him the developer role that i have already configured the role shows up here i would need to find my user whoever created and then assign him to that particular role so if you remember the user that i created was developer1 i would add this particular user and now this particular user what kind of a role i want him to have because this is the global rule that had created so developer i would assign this developer 1 to this particular global rule and i would go ahead and save my changes now let me check the permissions of this particular user by logging out of my admin account and logging back as developer one if you remember this role was created with very less privileges so there you go i have jenkins but i don't see a new item i can't trigger a new job i can't do anything i see these jobs however i don't think so i'll be able to start this job i don't have the permission set for that the maximum i can do is look at the job see what was there as a part of the console output and stuff like that so this is a limited role that was created and i added this developer to that particular role which was a developer role so that the developers don't get to configure any of the jobs because the jenkins instance is owned by a qr person he doesn't want to give developer any administrative rights so the rights that he set out by creating a developer role and anybody who is tagged any user who is tagged as a part of this developer role would get the same kind of permissions and this permissions can be you know fine grain it can be a project specific permissions as well but for now i just demonstrated the high level permission that i had set in let me quickly log out of this user and get back as the admin user because i need to continue with my demo with the developer role that was created i have very very less privileges one of the reasons for jenkins being so popular as i mentioned earlier is the bunch of plugins that is provided by users or community users who don't charge any money for these plugins but it's got plugins for connecting anything and everything so if you can navigate to or if you can find jenkins plugins you would see index of over so many plugins that is there all of these are wonderful plugins whatever connectors that you would need if you want to connect jenkins to an aws instance or you want to connect jenkins to a docker instance or any of those containers you would have a plugin you can go and search up if i want to connect jenkins to bitbucket bitbucket is one of the git servers there's so many plugins that is available okay so bottom line jenkins without plugins is nothing so plugins is the heart of jenkins for you to connect or for in order to connect jenkins with any of the containers or any of the other tool sets you would need the plugins if you want to connect or you want to build a repository which has got java and maven you would need to install maven and jdk on your jenkins instance if at all you're looking for a net build or a microsoft build you would need to have ms build installed on your on your jenkins instance and the plugins that will trigger ms build if at all you want to listen to some server side web hooks from github you will need github specific plugins if you want to connect jenkins to aws you need those plugins if you want to connect to a docker instance that is running anywhere in the world as long as you have the url which is publicly reachable you just have a docker plug-in that is installed on your jenkins instance sonar cube is one of the popular static code analyzers so you can connect jenkins build you can build a job on jenkins and push it to sonar cube and get sonar cube to run analysis on that and get back the results in jenkins all of these works very well because of the plugins now with that let me connect our jenkins instance to github i already have very very simple java repository up on my github instance so let me connect jenkins to this particular github instance and pull out a job that is put up there all right so this is my very very simple uh you know repository that is there called hello java and this is what is there in the repo there is a hello hello.java application that is here or a simple class file that is there it's got just one line of system.out so this is already present on github.com at this place and this would be the url for this repository if i pick up the https url this is my steepest url so what i would do is i would connect my jenkins instance to go to github provide my credentials and pull out this repository which is on the cloudhostedgithub.com and get it to my jenkins instance and then build this particular java file i'm keeping the source code very very simple it's just a java file how do i build my java file how do i compile my java file i just say java c and the name of my class file which is hello java and how do i run my java file i would say java and hello okay so remember i don't need to install any plugins now because uh what it needs is a git plugin so if you remember when we were doing the installation there was a bunch of recommended plugins so git is already installed on my system so i don't need to install it again so let me put up a new job here it says get job let it be a freestyle project that's good for me i would say okay all right so the source code management remember in the earlier examples we did not use any source code because we were just putting up some echo kind of uh jobs we did not need any integration with any of the source code systems so now let me connect this so i'm going to put up a source code and git would show up because the plugin is already there svn perforce any of those additional source code management tools if at all you would need just install those plugins and jenkins connects wonderfully well to all these particular source control tools okay so i would copy the https url from here i would say this is the url that i'm supposed to go and grab my source code from but all right that sounds good but what is the username and password so i'll have to specify a username and password all right so i would say the username this is my username and this is my https credential for my job okay so this is my username and this is my password i just save this i say add and then i would say you know use this credentials to go to github and then on my behalf pull out a repository all right if at all at this stage if there's any error in terms of not able to jenkins not able to find git or the git dot exe or if my credentials are wrong somewhere down here you would see a red message saying that you know something is not right you can just go ahead and kind of fix that for now this looks good for me i'm going to grab this url what am i going to do this step would pull the source code from the github and then what would be there as a part of my build step because this repository just has a java file correct hello.java so in order to for me to build this i would just say execute windows batch command and i would say java c hello dot java that is the way i would build my java code and if i have to run it i would just say java hello pretty simple two steps and this would run after the repository contents are fetched from github so java c java that sounds good i would say save this and let me try to run this okay if you see there's a lot of you know it executes git on your behalf it goes out here it provides my credentials and says you know it pulls all my repository and by default it will pull up the master branch that is there on my repository and it kind of builds this whole thing java c hello java and it runs this project java hello and there you see this is the output that is there and if at all you want to look at the contents of the repository if you can go here this is my workspace of my system hang on this is not right okay good job if you see here this is my hello.java this is the same program that was there on my github repository okay so this is a program that was there on the github repository all right so this was the same program that was here and jenkins on our behalf went over all the way to github pulled this repository from there and then you know it brought it down to my local system on my jenkins instance it compiled it and it ran this particular application okay now that i have integrated jenkins successfully with github for a simple java application let me build a little bit on top of it what i will do is i have a maven based web application that is up there as a repository in my github so this is the repository that i'm talking about it's called amv and web app it's got it's a maven based uh repository as you would know my one is a very very simple uh java based uh build tool that will allow you to run various targets and it'll compile it will based upon the goals that you specify it can compile it can run some tests and you can you can build a war file and even deploy it into some other server for now what we're going to use maven is just for building and creating a package out of this particular web application it contains a bunch of things and what is important is just the index.jsp it just contains an html file that is there as a part of this web application so from a perspective of requirements now since i'm going to connect jenkins with this particular repository get we already have that set we only need two other things one is maven because jenkins will use maven so in order to use maven jenkins would have to have a maven installation that is there on the jenkins box and in this case the jenkins box is this laptop and after i have my maven installed i also need a tomcat server tomcat is a very very simple web server that you can freely download i'll let you know how to quickly uh download and install the tomcat all right so download maven first and the various ways in which you can kind of download this maven there is zip files binary zip files and rkf files so what i've done is i've just already downloaded maven and if you see i've unzipped it here so this is the folder with which i have unzipped my maven so as you know maven again is is one open source build tool so you'll have to set in a few configurations and set up the path so mvn hyphen iphone version if i specify this after i set in my path my one should work and if at all i echo m2 home which is nothing but the variable environment variable specific to my onenote it is already set here so once you unzip maven just set this m2home variable to the directory where your unzip jmi1 also just set the path to this particular directory slash bin because that is where your maven executables are all found all right so that's with maven and you know since i've set the path and the environment variable maven is running perfectly fine on my system i just verified it okay next one is a tomcat server download apache tomcat server 8.5 is what i have on my system so i'm just going to show you where to download this from this is where you download tomcat server and i already have the server downloaded again this doesn't need any installation i just unzip it here and it kind of has a bin and configuration i have made some subtle changes in the configuration first and foremost tomcat server also by default runs on port 8080. since we already have our jenkins server running on port 8080 we cannot let tomcat run on the same port there will be a port clash so what i've done i have configured tomcat to use a different port so if i go to this configuration file here there is a server.xml let me open this up here all right okay so this is the port by default it will be 8080 i've just modified it to 8081. so i've changed the port on which my tomcat server would run all right so that's one chain second change when jenkins kind of tries to get into my tomcat and deploy something for someone he would need some authentications so that he'll be alloyed deployment by tomcat so for that i need to create a user on tomcat and provide this user credentials to my jenkins instance so i would go to tomcat users.xml file here i've already created a username called deployer and the password is deployer and i've added a role called manager hyphen script manager hyphen script will allow programmatic access to the tomcat server so this is the role that is there so using this credentials i will enable or i'll empower jenkins to get into my tomcat server and deploy my application all right only these two things that is required let me just start my tomcat server first so i get into my bin folder i open a command prompt here and there's a startup.bat it's pretty fast it just takes a few seconds yes there you go tomcat server is up and running now this is running on port 8081 so let me just check if that looks good so localhost 8081. okay my tomcat server is up and running that sounds good the user is already configured on this that's also fine so what i'll do as a part of my first job my one is also installed on my system so i'm good to use maven as a part of my jenkins so i will put up a simple job now i will say job mbn web app i call this freestyle job that's good okay so this will be a git repository what is the url of my git repository is this guy https url okay that's this url i will use the credentials the old credentials that i set up will work well because it's the same git user that i'm kind of connecting into all right so now the change happens here where after i get this since i said this is a simple maven repository i will have some maven targets to run so the simple target first is let me run maven package this creates a war file okay so mvn package is the target package is the target so when whenever i run this package it kind of creates it it builds it it tests it and then creates a package so this is all that is required maybe let me try to save this and let me first run this and see if it connects well if there's any problem with my war file or the war file gets created properly okay wonderful so it built a war file and if you see it all shows you what is the location where this war file was generated so this will be the workspace if you see this this war file was successfully built now i need to grab this particular war file and then i would need to deploy it into tomcat server again i would need a small plugin to do this because i need to connect tomcat with my jenkins server let me go ahead and install the plugin for the container deployment so i would go to manage plugins available type in container container container deploy to container okay so let's put this the plugin that i would need i will install it without a restart right seems to be very fast nope sorry it's still installing okay it installed the plugin so if at all you see this if you go to my workspace okay in the target folder i would see this web application war file that is already built so i would need to configure this plugin to pull up this war file and deploy it onto the tomcat server for deploying onto the tomcat server i will use the credentials of the user that i've created okay so let me go to configure this particular project again and um okay all this is good so the package is good i'm gonna just create a package that's all fine now add a post build step so after the war file is built as a part of this package directive let me use this deployment to container now this will show up after you install the plugin so deploy this one to the container now what is that you're supposed to specify you're supposed to specify the what is the location okay so this is a global uh you know configuration that is there that'll allow you to from the root folder it'll pick up the war file that is there so star star forward slash star dot war that's good for me okay what is the context path context path is nothing but just the name of an application that you know under which it will get deployed into the tomcat server i will just say mvn web app that's the name of my thing now i need to specify what kind of a container that i'm talking about all right so the deployment would be for this tomcat 8.5 is what i need okay because the server that we have is a tomcat 8.5 server that i have so this would be the url so the credentials yes i need to add a credential for this particular server so if you remember i had created a credential for my web application so let me just find that my tomcat server yes configuration of this okay so deployer and deployer username is deployer password is deployer okay so let me use that credential i would say i would say add a new credential jenkins credential the username is deployer and the password is deployer so i would use this deployer credentials for that and what is the url of my tomcat instance so this is the url of my tomcat instance so take the war file that is fine found in this particular folder and then you know context path is same in web use the deployer deployment credentials and get into this local host which is there 8081 this is the tomcat server that is running on my system and then go ahead and deploy it okay so that is all that is required so i would say just save this and let me run it now okay it builds successfully built the war file it is trying to deploy it and looks like the deployment went ahead perfectly well so the context path was mvn web app so if i type in this all right if at all i go ahead into my tomcat server there would be a web apps folder you would see the you know the date timestamp so this is the file that get got recently copied and this is the explorer version of our application so the application was built the source code of this application was pulled from the github server it was built locally on the uh jenkins instance and then it was pushed into a tomcat server which is running on a different port which is 808.1 now for this demo i'm running everything locally on my system but assuming that you know this particular tomcat instance was running on some other server with some other different ip address all that you've got to go and change is the url of the server so this would be the server in case you you already have that you know if you have a tomcat server which is running on some other machine that's all fine with a different ip that's all good enough the whole bundle or the war file that was built as a part of this jenkins job gets transferred onto the other server and gets deployed that's the beauty of jenkins and automatic deployments or other deployments using jenkins and maven distributed build or master slave configuration in jenkins as you would have seen you know we just have one instance of jenkins server up and running all the time and also i told you that whenever any job that kind of you know gets started on the jenkins server it is little heavy on in terms of disk space and the cpu utilization so which kind of you know if at all you're in an organization wherein you're heavily reliant on the jenkins server you don't want your jenkins server to go down so that's when you kind of start distributing the load that is there on the jenkins server so you primer will have a server which is just a placeholder or like a master will take in all kind of jobs and what you'll do is based upon trigger that has happened to the job or whichever job needs to be built he if at all he can delegate these jobs onto some other machines or some other slaves you know that's a wonderful thing to have okay use case one use case two assuming that you know if you have a jenkins server that is running on a windows box or on a linux one and if at all you have a need where you need to build based upon operating systems you have multiple build configurations to support maybe you need to build a windows you know windows based dotnet kind of a projects where you would need a windows machine to build this particular project you also have a requirement where you want to build linux linux based systems you also have a mac you you support some sort of an apps or something that is built on mac os you would need to build you know mac based system as well so how are you going to support all these needs so that's where in a beautiful concept of master slave or you know primary and delegations or agent and master comes into play so typically you would have one jenkins server who will just you know configure with all the proper authorizations users configurations and everything is set up on this jenkins server his job is just delegations he will listen to some sort of triggers or based upon the job that is coming in he will if there is a way nice way of delegating these jobs to somebody else and you know taking back the results he can control a lot of other systems and these systems may not have a complete or there's no need to put in a complete jenkins installation all that you got to do is have a very very simple runner or a slave that's a simple jar file that is run as a low priority thread or a process within these systems so with that you can have a wonderful distributed build server that can be set up and in case one of the servers goes down your master would know that what went down and kind of delegate the task to somebody else so this is the kind of distributed build or the master slave configuration so what i'll do in this exercise or in this demo is i will set up a simple slave but since i don't have too many machines to kind of play around what i'll do is i will set up a slave in in one other folder within my hard drive so i've got the c drive and d drive my jenkins is on my c drive so what i do is i would just use my e drive and set up a very very simple slave out there i'll just show you how to provision a slave and how to connect to a slave and how to delegate a job to that slave let me go back to my jenkins master and configure him to you know talk to an agent so there are various ways in which this client and server talk to each other what i'm going to choose is something called as jnlp java network launch protocol so using this i would ensure that you know the client and server talk to each other so for that i need to ensure that i kind of enable this jnlp port so let me try to find out where is that let me try this okay yes agents and by default this jnlp agent's thing would be disabled so if you see here there's a small help on this so i'm going to use this jnlp which is nothing but java network launch protocol and you know i'll configure the master and server to talk to each other using jlp so for that i need to enable this guide so i enable this guy instead of making the by default the configuration was disabled so i make him random i make him you know enabled and i say save this configuration all right so now configured or has made a setting for the master so that the jlp port is kind of opened up so let me go ahead and you know create an agent so i'll go to managed nodes so if you see here there's only one master here so let me provision a new node here so this is the way you know in which you bring up a new node you have to configure it on the server jenkins would put in some sort of security around this particular agent and let you know how to launch this particular engine so that he can connect to jenkins master so i would say new node i would give a name for my node i would say windows node because both of these are windows only so that's fine i just give an identifier saying that windows note i would say this is a permanent agent i'll say okay so if you see the name let me just copy this name here with the description number of executors since it's a slave node and both of these are running on my system i'll keep the number of executors as one that's fine remote root directory now this is where let me just clarify this since i have both my my master is running on my c drive c drive program files 86 or not 86. c column program files it is indeed 86 all right jenkins so this is where my master is running so i don't want the c drive what i'll do is i'll use something called as a drive i have another drive in my system but please visualize this like you know you're running this on a separate system altogether so i create a folder here called jenkins node and this is where i'm going to place my or i'm going to provision my slave and i'm going to run him from here so this is the directory in which i'm going to provision my slave node so i'm going to copy this here and that is the remote root directory of your particular agent or slave so i just copied here the label you know probably this is fine for me and usage how do you want to use this guy so i would don't want him to run all kinds of jobs i will only build jobs with label expressions that match this particular node and so this is the label of this node so in order for somebody to kind of delegate any task to them they'll have to specify this particular label so imagine this way if i have a bunch of windows mesh system i name it as windows star anything that says from windows i can give a regular expression and say that anything that matches windows run this particular task there if i have some mac machines i name all these mac agents as a mac star or something like that and i can delegate all tasks you know saying that start with whatever starts with mac this node run the mac jobs there so you identify a node using the label and then delegate the task there all right so launch method you know we will use java web start because we're gonna we're gonna use jnlp protocol okay that sounds good directory i think nothing else is required availability yes we'll keep this agent yep online as much as possible that sounds good all right let me save this all right i'm just provisioning this particular node now so if i click on this node i get a bunch of commands along with an agent.jar so this is the agent.jar that has to be taken down to the other machine or the slave node and from there i need to run this along with a small security credential so let me copy this whole text here in my notepad not bad plus plus is good for me okay i copy this whole path there i also want to download this agent.jar i would say yes this agent.jar is the one that is configured by our server so all the details that is required for launching this agent.jar is found in this ah sorry for launching this agent is found as agent.jar so typically i need to take this jar file onto the other system and then kind of run it from there so i have this alien.jar i copy this or i cut this i come back to my folder my jenkins node i paste it here okay so now with this provision agent.jar and i need to use this whole command ctrl a ctrl c and then launch this particular agent so let me bring up a command prompt right here and then launch that so i'm saying in the same folder where there is agent.jar i'm going to launch this a particular agent java hyphen jar agent.jar jnlp this is the url of my server in case the server and client are on different locations or different ips you have to specify the ipad address all these any way would show up and then the secret and you know the root folder of your jenkins or the slave node okay so something ran and then you know it says it's connected very well it seems to connected very well so let me come back to my jenkins instance and see you know if you told me you see earlier this was not connected now let me refresh this guy okay now these two guys are connected provision a jenkins node and then i copied all the credentials or the slave.jar along with the launch code and then took it to the other system and kind of ran it from there since i don't have another system i've just got a separate directory in another folder another drive and i'm launching the agent from here as long as this particular agent is up and running or this command prompt is up and running the agent would be connected so once i close this the connection goes down all right so successfully you've launched this particular agent now this would be the home directory of this jenkins node or the jenkins slave so any task that i'm going to delegate to this particular slave would all be run here it'll create a workspace right here all right so good so let me just come back and let me kind of put up a new task here i will say that you know delegate job is good i say freestyle project i'm going to create a very very simple job here i don't want it to connect to gate or anything like that let me just create a very very simple echo relegated to the slave related to i don't like the word slave delegated to agent put this way all right so delegated to agent sounds good now how am i going to ensure that this particular job runs on the agent or on the slave that i've configured right you see this if at all you remember how we provisioned our particular slave we gave a label right so now i'm going to put in a job that will only match this particular label so i'm going to say that whatever matches this you know windows label run this job on that particular node so we have only one node that's matching this in a windows node so this job will be delegated out there so i save this and let me build this this is again a very very simple job there's nothing in this i just want to demonstrate how to kind of delegate it to an agent so if you see this it ran successfully and where is the workspace the workspace is right inside our jenkins node it created a new workspace delegated job it put in here so my old order my primary master job is in sql program files under jenkins and this is the slave job that was successfully run very very simple but very very powerful concept of master slave configuration or distributed built in jenkins okay approaching the final section where we've done all this hard work in bringing up our jenkins server configuring it putting up some jobs on it creating users and all this stuff now we don't want this configuration to kind of go away we want a very nice way of ensuring that we backup all this configuration and in case there is any failure hardware crash or a machine crash we would want to kind of restore from the existing configuration that we kind of backed up so one quick way to do that would be or one dirty way to do that would be just you know take a complete backup of our colon program files colon jenkins directory because that's where our whole jenkins configuration is present but we would don't want to do that let's use some plugins for taking up a backup so let me go to manage in cans and click on available and let me search for some back there are a bunch of backup plugins so i would recommend one of these plugins that i specifically use so this is the backup plugin so let me go ahead and install this plugin all right so we went ahead and installed this plugin so let me come back to my manage plugins stop this plugin is there so hang on backup manager so you will see this option once you install this plugin so first time i can you know do a setup i would say back up this particular i'll give a folder uh this folder is pertaining to the folder where i want jenkins to backup some data and i would say the format should be zip format is good enough let me give a name or a template or a file name for my you know backup this is good i want it in verbose mode i don't want to shut on my jenkins or should i shut it down no okay one thing that you got to remember is that whenever a backup happens if there are too many jobs that is running on the server it can kind of slow down your jenkins instance because it's it's in the process of copying few of those things and the files are being changed at that moment it's little bit problematic for jenkins so typically you back up your servers only when there is very less load or typically try to you know bring it to a shutdown kind of a state and then take a backup all right so i'm going to backup all these things you know i don't want to exclude anything else i want the history i want the maven artifacts possibly i don't want this guy i would just say save and then i would say back him up so this would run a bunch of you know steps and all the files that is required as a part of this is pretty fast but then if at all you have too many things up on your server for now we didn't have too many things up on our server but in case you had too many things to kind of backup this may take a while so let me just pause this recording and get back to you once the backup is complete so there you go the backup was successful created a backup of all the workspace the configurations the users and you know all that so all this is kind of hidden down in this particular zip file so at any instance if at all i kind of crash my system for some instance or say hard disk failure and i bring up a new instance of jenkins i can kind of use the backup plugin for restoring this particular configurations so how do i do that i just come back to my manager cans come back to backup manager and i will say restore that's an or jenkins configuration now that we know what is continuous integration and where does jenkins come into picture let's look at the rest of the tasks of our software development lifecycle so if at all i were to visualize the kind of steps that is involved in delivering my software possibly the continuous integration phase would be somewhere here where multiple developers are developing on that and then we have a little bit of a stable code that is there that can be kind of moved across because i want to go ahead with the particular build that i have and then i want to migrate that i want to propagate that across various environments so if you consider the standard software delivery approach in the first cycle you just do some minimal testing and then you kind of move that to one of the environments and from there you kick off more and more tests they could be integration test they could be acceptance test they could be functionality check they could be a stress test there could be a load test it could be a system integration test all kinds of tests that you can think about and all the way may be propagating the build across various environments if all this can be considered as various steps the workflow is such that as and when the build moves across various phases if there's any failure of course the build propagation kind of stops everyone gets notified but if at all everything goes well so your workflow is progressing well and at the end of the workflow you eventually have a code which is pretty much good to release now mind you i make an assumption here that most of your test cases are automated and you have a good percentage of coverage of your test cases but if that is not the scenario then possibly there are some automated tests or checks that may be required in between but if the workflow can kind of accommodate all that as well you know you can visualize this as the steps that is required for your software development or software delivery life cycle now in jenkins the way this kind of translates is that each of these tasks can be put out as a job so now let me quickly let you know or let me quickly demo what existed in pre-jenkins 2.0 where i could put up a couple of jobs and i can connect them using the upstream downstream linking mechanism so if this job one if at all it is a build and even test cases if at all that passes successfully job 2 gets triggered if the job 2 is more about running some more automated tests or possibly deploying it to environment and then kicking off some more test cases that would be job too but if the deployment fails or if some of the other test cases fail it would not propagate to the third job all right so let me quickly bring up my jenkins instance and put up some sample jobs and tell you how to connect that or rather how could one connect that using jenkins 2.0 or pre jenkins 2.0 release i have now brought up my jenkins instance and in case some of you don't know how to install jenkins or you don't know how to bring up your jenkins instance i would strongly recommend that you watch our previous videos on simply learn youtube channel where i've detailed out the steps that is required for you to install jenkins and bring it up so alright so i brought up my jenkins instance let me put up few of those jobs now mind you i'm going to cover the pre jenkins 2.0 feature here alright so let me put up my first job all right i hope i don't have that job i say it's a freestyle project i don't want to change anything i'm going to put up a very very simple job here it's in batch command let's say echo first job triggered at right that's my first job now let me put up my second job freestyle project all right that's my second job all right that's my third job i've got a very very simple echo statement in this so it just prints out the system date and the time in it all right so i could run these jobs individually if i want so let me just check running my third job so this is what i get and the console output third job triggered at date and time oops let me fix that right that should fix it let me check my second job all right that's my second job all right so i've got three jobs now if i were to link them together or if at all i want a scenario where after the first job is successfully run i would like to trigger my second job so i would do a small configuration change in here i would say after this first job is run i want to trigger the second job so i have something called as a post build action so i can say that trigger some other jobs from here so if you see this publish record deploy all right trigger trigger trigger trigger let me check the other one build other projects this is what i would want to do so after the first job is done i want to trigger my second job all right i would say save this now let me go back to my second job and then trigger the third job after the second job is done all right i'll add this post build build other projects third job again i'm not really sure if you guys notice this there is various configurations as to when exactly do you want to trigger the other job and the default one is trigger only if the build is stable so typically this is the configuration that would need we definitely don't want the third job to be triggered in case the second job fails all right so this is the combination that i want or this is the choice that i want and i save this now i have three of my jobs if you see this the second job the upstream job is the first job so let me check this kind of a pipeline what i've set here is a very very simple pipeline so after my first job gets triggered if i build this guy right the second job gets triggered after the build first job is built so if i click on the second job all right so the first job was to get the second job and after the second job it is triggering the third job so this is how first job second job and third job were kind of linked but it's pretty hard to visualize this as to you know if i need to see one holistic picture where after the first job after the second job after the third job what was the flow it's not possible for me to visualize that that's where in i install a plugin so let me go to manage plugins right here i think i already have it installed for those of you don't have it installed you can go to the available button i mean available tab and click on that the plugin is called delivery pipeline plugin i already have it installed in case you don't have it installed you just go to the available you click on this and say install without restart this is the plugin that i want you to install all right so now we have that plugin installed so what i want to do is after the plugin is installed you see something like this so this is where i would create a new visualization for the pipeline that i've created so i would say my first pipeline or i give a name for my visualization i would say yes this upstream downstream dependencies this is exactly what i want and there are a bunch of settings here i'll not look at any of that now what i want is i just want to tell this view that you know i can give a name for this i would give it as simply learn pipeline and what's important is that i specify what is the first job that should be picked up as a part of this pipeline and the final job is optional because it knows that if the first job is triggering those other jobs it knows where to end this whole life cycle so i define a pipeline and give a name for my component and initialize that as my i mean i give it the first job so i say okay and there you go this is much better this gives you a beautiful visualization of as to what happened after the first job second job was run second job if i click on any of these that will in fact take me to that job all right there is also one other option which is pretty good option in my opinion which is about edit view yes this is where it is enable start of a new pipeline build let me apply and let me click ok on this what it gives me is a way in which i can trigger my whole pipeline from here so if i click on this there you see the first job getting trigger the second job is still running the green means it's all run properly and nicely second one is triggered now the third one it's still running all right so this is the pipeline that existed prior to jenkins 2.0 this is pretty decent enough and if you see there's a one-to-one mapping but if at all you remember we could go and add multiple dependencies for the projects that i set in just to give an example let's say i go to my first job i can do a configuration here and nothing stops me from triggering multiple jobs after this by giving me a comma i can trigger multiple jobs here in case if i have to run few things parallely this also gives me that option to do that but having said that this was the most primitive way in which the jobs were kind of visualized and run prior to jenkins 2.0 now this feature became such an important feature the users wanted more and more complicated because the pipeline was not a lot complicated it was not just one job after the other there were multiple jobs that has to be run and there is also an introduction of the jenkins agents where multiple tasks could be parallel run on different agents so they wanted to club all of that and the pipeline could have all the such complicated stuff that's where in post chenkin 2.0 or in jenkins 2.0 jenkins released a version which has got the feature of pipeline which can be written in groovy scripts now groovy is wonderful scripting language it's very very powerful anybody can visualize your pipeline or write your pipeline using programming language and the point of everything as code where this whole groovy script gets into your source code repository so instead of putting jobs here and in case my jenkins kind of fails you know there's a crash on my jenkins i don't get back these jobs how do i bring back all these jobs back so everything has code that's the devops principle so the pipelines will be written as scripts that is what i'm going to do in my next exercise in my previous example i showed you the crude way in my opinion of putting up a jenkins pipeline but this is what existed prior to jenkins 2.0 and now i have post jenkins 2.0 in terms of my version jenkins version is 2.107. so this supports something called as a scripted pipeline wherein you can write your pipeline in terms of groovy scripts no need to put up any jobs here and remember how exactly you put up these individual jobs you can write a pipeline script in terms of groovy language let me quickly show you a very very simple and elementary pipeline that i have this is what a groovy script would look like pipeline any agent can run this stages there are individual stages that is defined as a subset of these stages so the first stage is the compile stage and stage has got some steps in it you can have multiple steps in it and once only after all these steps successfully complete that's when the stage gets through perfectly with the pass so there's a compile a stage there's a j unit stage there's a quality gate stage there's a deploy stage and i'm really not doing anything much within this other than echoing you know some text within each of these stages and what's interesting is at the end there's something called as a post which is similar to or you can kind of equate that to what would be there in a try catch kind of a block supposed always meaning this would run all the time success only if at all all the steps that were above in terms of the stages they were completed successfully without any failures so typically you would have your email that is going out here saying that the build is successful and stuff like that failure if something went bad if any of the step resulted in a failure this particular block will get executed unstable whenever any build is marked unstable if at all only few things that failed within your test run and you would want to mark the build as unstable are changed this is an interesting option so this compares the present run with the previous run and if there's any change meaning if the previous run was a failure and the present run is a success or vice versa this would get triggered so this is what a simple pipeline script would look like so let me copy this pipeline and let me put up a simple job for running this pipeline so let me open up my jenkins say a new i would say scripted pipeline yeah this is what i want i don't want to choose a freestyle project this is going to be a pipeline project so i would say pipeline and say okay all right this has got far less options than the other jobs that we put up so general i don't want anything here i don't want any build trigger right so this is where i kind of i can paste in whatever i had copied there's also something called as a pipeline syntax or a syntax generator this is like a lookup where you can choose what you want to do and choose the option that is specific to those steps and you will get a pipeline generator or a script generated for you jenkins knows that you're not very good at understanding these pipelines so this gives you this sandbox kind of an environment where you can check out whatever you want to do as a part of your pipeline and then get the equivalent groovy script from here let me look at this in a bit later so for now i have my pipeline syntax already copied so what i'm going to do is i'm going to paste what i copied all right so this looks good okay i'm not connecting to any github repository of any of that i'm just running a very very simple pipeline which has got some steps in it and it just compiles or rather it just puts out some messages saying that this stage completed successfully and stuff like that so let me save this and let me try to run this scripted pipeline all right if you see this you'll see each of those steps going through and if at all i look at the console output compile successfully unit passed all the stages passed there was a pass the failures doesn't show up you will see the messages from our post or the try catch block that i was mentioning earlier so this is how one would put up a pipeline and you also get to see the visualized view of your pipeline that says which stage run after which phase how much time did it take and you can click on any of these and get into looking at the logs from that particular pipeline front that was pretty easy wasn't it now let me give you another scenario for a pipeline wherein the source code of my pipeline would be in a github repository and i'll write scripts to grab this particular code and run some part of the code which is there as a part of the repository so let me look at the repository that i have i have a repository out here on the simply learn github account which is called the pipeline script and if you see in there there are a bunch of batch files that are there so the first batch file would be a build.batch so there's nothing in it except that it is just trying to build a particular project you can visualize this as individual batch files which actually contain the scripts for building running deploying and checking the quality gate of your particular project so i have a couple of batch files that is here and this is on the github repository so i would need to write jenkins job which will log into my github account and then check out this particular repository from my account and then run these batch files as a part of those individual steps within within the scripted pipeline so let me check as to how i could do that let me put up a new project for this let me call this scripted pipeline scripted pipeline from github all right so let this be a pipeline project that's good enough for me let me see my scripts all right now this is where i need to put in the scripts for pulling out the code repository from my github server and running those batch files that are there as a part of the repository so what i want to do is i already have the skeleton of my pipeline that is written which is very similar to whatever was the pipeline syntax that i showed you in the previous step so i just copy this out here and then paste it here so what i have here is i've written on the high level skeleton without really putting in the actual steps required for checking out rather or rather running those build scripts so i've got four steps one is the git checkout step the builds tab unit test quality gate and possibly the deployment all right so i need to put in the actual scripts that is required for first checking out the repository from my github server so this is where i will make use of this pipeline syntax so as i mentioned earlier you have a bunch of help that is available for you to figure out the actual scripts that is required for you to write within your pipeline so what i wanted to do is check out something from git so it's get related so search on git and you'll find this option so i got to specify my git repository url and my credentials so let me look at the repository url this would be my repository url so let me copy this i'm going to copy the https url of my repository and branch is good and one thing that you gotta notice is for now the repository is anyway a public repository on github so even though if you don't specify any credentials that would work for me still but in case you have a repository which needs strictly a username and password to be specified you can kind of add it out here using add jenkins and you can give your username and password out here but for now i don't need any of these things so i'm going to just say git checkout or rather the url of my repository and what we want is the master branch for now i have only one branch on my github server so this is good for me so this is what exactly i want to do as a part of the script so if i click this this is the script that i need to put in my build script so i come over here and this is what will check out the code from my repository all right so now once i get my code onto my repository from my repository rather it will grab those code all these batch files and get it onto my jenkins workspace now i'll have to run these batch files as a part of each of my step so let me look at what would be the syntax so the first one that i want to run would be my build.bat all right so i want to run a batch file all right and what is the name of the batch file that i want to run i want to run this build.bat so generate pipeline script this is all that i got to specify as a part of my build step and then unit test i've got to just change this to unit i think that's what i have in my repository okay that is unit and then deploy and quality queue capital and this one would be deploy all right so this piece of code will actually get into my repository and check out my source code and grab it and take it to the jenkins workspace so from this workspace since all the files are there in the root directory of this workspace it will run these batch files one after the other all right let me save this and let me try to run my pipeline all right so it runs a lot of things in the background trying to get the source code from my repository whoa whoa whoa that was fast all right so it pulled out all the source code from my repository the last commit message from where the source code was pulled out it was this create deploy dot bad that looks good i'm saying building checked out project building the checked out project this is what i've had in my build.pad if i'm not mistaken okay building the project that's what is there with the timestamp running unit test cases unit.bat it is running the unit.bat and then giving me the date and time time okay so all these kind of passed and if i go back to the project i will also see this beautiful view of how exactly what is the time that was taken for checking out the repository running the build on bat running the unit test cases quality gates and all this isn't that pretty simple now let me modify my previous job or rather let me put up a new job for making use of an agent wherein i could delegate a job to an agent typically agents can be brought up on any other remote machines other than where your primary engine can server is running in case you don't know or you don't know how to start up these agents i would strongly recommend that you refer to our previous jenkins video on the simply learn youtube channel all right so let me just check the status of my agent for now yes he's offline so let me start this agent because agent is not running so i have the agent uh set up in my sql on agents so let me copy the script file that is required for starting my agent let me go to the agents folder open up a command prompt and let me try to bring up my agent all right so the agent is up and running for now i don't have the luxury of starting my agent on a different machine so my agent is running on my same machine but the agent's workspace is sql agent while my primary jenkins server is running uh has the workspace out here sequel and program files 86 and this is the workspace of my jenkins all right i hope you can kind of differentiate those two all right so now what i want is i look at the same job that i put in earlier or rather modify that let the steps be the same but i don't want to run that on my master server let me try to delegate that using the script so let me put up an agent scripted job all right it will be a pipeline rep job let's see okay and let me copy this was a step that i had put in for my previous job so agent any so what i'm gonna do now is i don't want this to be running on any other agent i want this to be running on the agent whose label is let me check what is the label of my agent that is running okay so this is the name of my agent okay windows note so let me just copy that there all right so with a very subtle change instead of saying agent any i'm going to run or rather i'm going to specify the agent who will be running this job is the one who has got the label as windows note so this agent that i brought on my system has got the name as windows node and it is configured to pick up any job that matches the label to which any job is kind of delegated so let me come back to my jobs where is my scripted agent job i've got too many jobs running all right so this is my agent scripted job that i left halfway through so here in the pipeline what i'm going to do is this is all i'm going to need so the job remains the same git checkout is going to check out from the same repository run the batch files accordingly but this change is just to ensure that this job is kind of delegated on the agent all right so this would be my agent job let me save this and let me get back to the dashboard and let me run it from here if you see this you know the master and agent are both idle as of now let me try to run this agent scripted job all right so the agent kind of kicked in and there was a job that was delegated to the agent if i look at what is there in the console output he's pretty much doing whatever was there as a part of the job but the interesting thing to notice that this is the new workspace or rather this is delegated to the agent and the agent's workspace is this particular folder so this is where it's going to get all this stuff run the whole thing and you know the flow is pretty much the same the only thing is this whole thing ran on the agent if i need to check my agent i would see the workspace out here agent scripted job if you look at this all the batch files are here and this is where the job was kind of delegated to run so with a very subtle change in in the scripting i can ensure that the jobs are kind of delegated onto the agent the pipeline job specifically as i mentioned earlier jenkins provides you two different ways of writing pipelines called the scripted and the declarative the first one that was launched was the scripted pipeline this is heavily based on groovy scripting since jenkins ships along with the groovy engine so this was the first script or the first support for pipeline that was provided by jenkins in 2.0 this needs a little bit of a learning curve since groovy is a wonderful script understanding that may be a little cumbersome but then once you kind of master it you can write really powerful scripts based on groovy at a very high level this is what a typical scripted pipeline would look like something called as a node node represents the agent or the actual box on which your job would be running and then a bunch of stages are put out with each of the stage along with the steps that needs to be covered as the part of those stages listed one below the other so all these stages if they're run peacefully then the whole task is kind of marked as run successfully since understanding groovy or learning grouping was a little tough for many of the people so this is a new one from jenkins where it provides you a much simple and friendly syntax for writing pipelines without really needing to understand or without nearly reading to learn some group scripting again there's a very subtle change between these and you there are a lot of lookups for figuring out what is a better pipeline for you to kind of write but if you can figure out the difference or if you can try to find that particular piece of code which kind of helps you out with your pipeline either of the skips there's not really any difference in writing or kind of delivering your pipeline using either of these two methods all right so declare your pipeline is something like this where you have an agent you can specify the agent label or if you can say agent any it will pick up whatever is an available agent and run the job and then you have something called a stages stages is nothing but a collection of stage and stage could have multiple steps defined within this so if any of the steps in any of the stage fails then that particular complete stage and the build is marked as failure so very subtle difference between both these uh two syntax but using either of these you can write powerful scripts for your pipeline now let me come up with an example where i'm going to at least demo one of the feature where you could run a master and a slave job in parallel so let me come up with a demo for that particular scenario let me put up a new job for my parallel agent pipeline let me call this and this would be a pipeline project i don't want anything here let me look at the pipeline script that i have pipeline agent none stages and there's a first stage where this would be a kind of non-parallel stage where there's a need for you to possibly pull out the source code from one of the repositories and possibly unit test it if all the unit test cases pass then possibly you want to deploy it to one of the test environments that would be what would be there as a part of the non-parallel stage and then you may have a bunch of tests that could be run and assuming that you know you have a windows node you have a linux node you have some other kind of an operating system based node you could run these stages in parallel so for just for demonstration i've just put in two parallel stages in parallel is the keyword that you're going to use for running tests parallely so i would say parallel stage test on windows and i'm going to run this in my windows note well i could run a bunch of steps that i want out here and then in the other stage or other step what i want is i will run something else on on my master as long as this parallel keyword is encountered jenkins will ensure that these two stages are run parallely for now i have both these things running on my same machine but assuming that these were running on different boxes you could kind of visualize it as these two steps are going to be started parallely without really any dependency on each other and then you could wait for the test results and then based upon whether both of these steps passed or failed if one of them failed then we could kind of mark the build accordingly so let me copy this pretty pretty simple script let me put this out here and now let me save this out and let me try to build this all right there you go the stage will be executed first this is the non-parallel stage that's going to happen then the task 1 on agent task 1-1 master followed by as i said since i have only one node or rather one system one with both these things are running simultaneously you will not really see a benefit of this but assuming that you have a couple of boxes on which you have multiple agents running you will possibly want to run your selenium tests on the windows box because selenium brings up some of those ui which needs a browser you could possibly need some regression test that could run on linux boxes or linux agents and then you can kind of break down your tasks into multiple things that is running on multiple systems at the same time and then collate all the results okay one final thing all right now i have all my particular job or rather the steps required for my pipeline put down in terms of the scripts and this is saved in this particular job that's not a good a recommended approach so what i'll do is i'll copy all of these steps out here and then what needs to be done is actually let's say let me go back to this repository the most preferred approach is where you create something called as a jenkins file jenkins file and you paste all the scripts that is required for your pipeline now this is in a true sense the devops approach where i'm going to save this out so if at all you have a pipeline defined for your project uh the best place to kind of put out your configurations for the pipeline is within your repository so this may be a different project that i was referring to but assuming that you have your project where you know you have to define your pipeline instead of putting that as a particular job on jenkins and fearing that if jenkins fails or the jobs if there's a crash and then you lose out your job configuration the best approach is to use a jenkins file put all the steps that is required the try tested steps that is required as a part of your jenkins file and then you can put out a job that can pull the source code from here as well as use the steps that is defined in the jetkins file so let me end up by putting up another job which is a true jobs kind of a job so i would say devops pipeline and this is a pipeline script and then i'm not going to say any of these things i would say the pipeline script is from the source code management so my pipeline script is already defined it is present in scm so what is my svn i mean what is my source code repository this is my source code repository where i already have this so let me copy this url this is my url i don't need any credentials because the repositories anyway in public repository that is all that is required i would say and the scripted file it automatically picks up jenkins file all right so let me save this let me build this so that's the beauty of devops wherein i have a pipeline that is defined and instead of putting the pipeline as a job because pipeline is nothing but a configuration the configuration is also checked into the source code repository and any changes to this pipeline instead of putting that modifications in the job these are all captured as a part of my repository so the changes are nicely configured so that you know we know who's done what change we have almost reached the end of this tutorial now matthew will help you learn some of the most important devops and jenkins questions that you might tackle in any devops interview hello this is matthew from simply learn and today we're going to go through part one of a two-part series on interview questions that you are likely to be asked if you are interviewing for a job that focuses on devops so let's just get into those general devops questions so one of the questions that you're going to be asked is how is devops different from agile and the reality is is that devops is a cultural way of being able to deliver solutions that's different from agile if we look at the evolution of delivery over the last five to ten years we've gone from waterfall based delivery to agile delivery which is on uh sprints to where we are with continuous integration and continuous delivery around devops the whole concept of devops is culturally very very different from agile and the difference is is that you're looking at being able to do continuous releases what does that mean the difference is is that you want to be able to send out code continuously to your production environment that means the operations team the development team have to be working together that means that any code that gets created has to be able to go to production very quickly which means you need to be testing your code continuously and then that production environment must also be able to be tested continuously and any changes or any errors that come up have to be communicated effectively and efficiently back to the dev and op team another area in which i see that devops is different is really the response that we have for how we engage with the customer so the customer is coming to your website to your mobile app to your chat bot or any digital solution that you have and has an expectation when you're going through and actually doing a dev ops paradigm the old model would be that you would capture requirements from the customer then you do your development then you do your testing and there would be these barriers between each of those as we move faster through from waterfall to agile what we saw is that with agile we were able to respond much faster to customer demands so instead of being weeks or months sometimes in some cases years between releases of software what we saw it would was a transition to weeks and months for releases on software now we see with devops is that the release cycle has shrunk even further with the goal of continuously delighting the customer how further has that release cycle shrunk to there are companies that have gone from having releases of once a week or once every two weeks or once a month to now having multiple releases a day indeed some companies have up to 50 releases a day this isn't something to also bear in mind is that each of those releases are tested and verified against test records so that you can guarantee that the code that's going to production is going to be good continuous code so what are the differences between the different phases of devops so effectively there are two main phases of devops there's the planning and coding phase and then there's the deploying phase and you have a tool such as jenkins that allows you to integrate between both environments some of the core benefits that you may have to devops are going to be some technical benefits and some business benefits so when somebody asks you what are the benefits of devops you can reply that from a technical point of view you're able to use continuous software delivery to constantly push out code that has been tested and verified against scripts that have been written and approved you can be able to push out smaller chunks of code so that when you have an issue you're not having to go through massive blocks of code or massive projects you're going through just very small micro services or small sections of code and you're able to detect and correct problems faster on the business side the benefits are absolutely fantastic from a customer that's coming to your website and or to your mobile app they're going to see responses happening continuously so that the customer is always aware that you as a company are listening to their demands and responding appropriately you're able to provide a more stable environment and you're able to scale that environment to the demands of the number of customers that are using your services so how you approach a project that needs to implement devops so this is really an exciting area for you to be in so there are effectively three stages when it comes to actually working in a dev ops the first stage is an assessment stage and think of this as the back of the napkin ideation stage this is where you are sitting with a business leader and they're giving you ideas of what they would like to see from feedback that they've had from their customers this is blue sky opportunity this is thinking of big ideas that second stage and this often comes as a fast follow to stage one is actually proving out that concept so developing a proof of concept and a proof of concept can actually be a multiple different things so it could be something as simple as a wireframe or it could be something that is as complex as a mini version of the file application depending on the scope of the work that you're delivering will really depend on how complicated you want the poc to be but with that in mind whatever choice you make you have to be able to deliver enough in the poc so that when you present this to a customer they're able to respond to that creation that you've developed and able to give you feedback to be able to validate that you are going with the right solution and able to provide the right product to your customers that third stage is where you get into your dev ops stage and this is just the exciting part this is where the rubber hits the road and you start releasing code based on a backlog of features that are being requested for the solution in contrast to doing agile delivery where you just continuously work through a backlog with devops what you're also looking at is putting in analytics and sensors to be able to validate that you are being successful with the solution that being delivered so that once you actually start delivering out code that customers can interact with you want to be able to see what are the pieces of the solution that they are using what do they like what is complicated where are the failure points and you want to use that data and feed that back into your continuous integration and have that as a means to be able to back fill the demand of work that gets completed in the bank log so what is the difference between continuous delivery and continuous deployment so continuous delivery is based on putting out code that can be deployed safely to production it ensures that your businesses and functions are running as you would expect them to be so it's going through and completing the code that you'd actually see continuous deployment in contrast is all about ensuring that you're automating the deployment of a production environment so you're able to go through and scale up your environments to meet the demands of both the solution and the customer this makes software development and release processes much more faster and more robust so if we look here we can actually see where continuous integration and continuous deployment come hand in hand so when you actually start out with the initial pushes of your code that's where you're doing your continuous integration and your continuous delivery and then at some point you want to get very comfortable with deploying the code that you're creating so it's being pushed out to your production environment one of the things that's great about working with the tools that you use in a devops continuous integration and continuous delivery model is that the development tools that you use the containerization tools the testing tools should always reflect the production environment what this means is that when you actually come to deploying solutions to production there are no surprises because your development team have been working against that exact same environment all the way through so a question that you'll also be asked is you know what is the role of the configuration management in devops and so the role of configuration management really has three distinct areas and the first and this is really obvious one and this is the one where you probably already have significant experiences is the ability to manage and handle large changes to multiple systems in seconds rather than days hours or weeks as that may have happened before the second area is that you want to also demonstrate the business reasons for having configuration management and the business reason here is that it allows it and infrastructure to standardize on resource configurations and this has a benefit in that you're able to do more with fewer people so instead of having a large configuration team you can actually have a smaller more highly skilled team that's able to actually manage an even larger operational environment and thirdly you want to be able to highlight the ability to scale so if you have configuration management tools you're able to manage a significant number of servers and domains that may have multiple servers in it allows you to effectively manage servers that are deployed on cloud or private cloud and allow you to do this with high accuracy so how does continuous monitoring help and maintain the entire architecture of the system so when this question comes up you want to dig in and show your knowledge on how configuration and continuous monitoring is able to control an entire environment so the number one topic that you want to bring up when it comes to continuous monitoring is that with being able to effectively monitor your entire network 24 7 for any changes as they happen you're able to identify and report those faults or threats immediately and respond immediately for your entire network instead of having to wait as it happens sometimes for a customer to email or call you and say hey your website's down nobody wants that that's an embarrassing thing the other three areas that you want to be able to highlight are the ability to be able to ensure that the right software and the right services are running on the right resources that's your number one takeaway that you want to be able to give of continuous monitoring the second is to be able to monitor the status of those servers continuously this is not requiring manually monitoring but having a agent that's monitoring those servers continuously and then the third is that by scripting out and continuously monitoring your entire environment you're creating a self-audit trail that you can take back and demonstrate the effectiveness of the operations environment that you are providing so one of the cloud companies that is a strong advocate for devops is amazon's web services aws and they have a really five distinct areas them that you can zero in on board services so when the question comes up what is the role of aws in devops you want to really hold out your hand and list of five areas of focus using your thumb and finger so you want to have flexible services built for scale automation secure and a large partner ecosystem and having those five areas will really be able to help demonstrate why you believe that aws and other cloud providers but aws is certainly the leader in this space are great for being able to provide support for the role of devops so one of the things that we want to be able to do effectively when we're releasing any kind of solution is to be able to measure that solution and so kpis are very important so you will be asked for three important dev of kpis and so three that really come to mind that are very effective the first one is mean time to failure recovery and what this talks about is what is the average time does it take to recover from a failure and if you have experience doing this then look at the experience you have and use a specific example where you are able to demonstrate that mean time to failure recovery the second is deployment frequency and with deployment frequency you want to be able to discuss how often do you actually deploy solutions and what actually happens when you're actually doing those deployments and what does the impacts to your network look like when you're doing those deployments and then the third one is really tied to that deployment frequency which is around what is the percentage of failed deployments and so and how many times did you deploy to a server and something happened where the server itself failed what we're looking for when you're going through and being asked for these kpis is experience with actually doing a devops deployment and being able to understand what devops looks like when you're pushing out your infrastructure and then the second is being able to validate that self-auditing ability and one word of caution is don't go in there and say that you have a hundred percent success uh the reality is that servers do degrade over time and you maybe want to talk about a time when a server did degrade in your environment and use that as a story for how you're able to successfully get over and solve that degradation so one of the terms that is very popular at the moment is infrastructure as code and so you're going to be asked to explain infrastructure as code and really it's it's something that actually becomes a byproduct of the work you have to do when you're actually putting together your devops environment and infrastructure's code really refers to the writing of code to actually manage your environment and you can go through many of the other tools that we've covered in this series but you'll see that xml or ruby or yaml are used as languages to describe the configuration for your environment this allows you to then create the rules and instructions that can be read by the machines that are actually setting up the physical hardware versus a traditional model which is having software and installing that software directly onto the machine this is really important when it comes to cloud computing there really is a strong emphasis of being able to explain infrastructure as a service and infrastructure as code is fundamental to the foundation to infrastructure as service and then finally allows you to be able to talk about how you can use scripted languages such as yaml to be able to create a consistent experience for your entire network all right let's talk about the next section which is continuous integration with jenkins so the first question you'll be asked about with jenkins is explain a master slave architecture of jenkins so the way that jenkins is set up is that the jenkins master will pull code from your remote git repository such as github and will check that repository every time there is a code commit it will distribute the workload of that code and the tests that need to be applied to that code to all of the jenkins slaves and then on request the jenkins master and the slaves will then carry out all the builds and tests to be able to produce test reports the next question you'll be asked is what is a jenkins file and simply put a jenkins file is a text file that has a definition of the jenkins pipeline and is checked into a source code repository and this really allows for three distinct things to happen one allows for a code review and iteration of the pipeline it permits an audit trail for that pipeline and also provides a single source of truth for the pipeline which can be viewed and edited so which of the following commands runs jenkins from the command line is it java jar jenkins dot war java dash war jenkins.jar java.jar jenkins jar java dash war jenkins.org and the answer is a java jar jenkins.war so when working with jenkins you're going to be asked what are the key concepts and aspects of working with a jenkins pipeline and you want to really hold out your fingers here and go through four key areas and that is pipeline node step and stay so pipeline refers to the user-defined model of a cd continuous delivery pipeline node are the machines which is which are part of that jenkins environment within the pipeline step is a single task that tells jenkins what to do at that particular point in time and then finally stage defines a conceptually distinct subset of tasks performed through the entire pipeline and tasks could be build test and deploy so which of the following file is used to define dependency in maven and do we have a build.xml b palm.xml c dependency.xml or d version.xml and the answer is palm.xml working with jenkins you're going to be asked to explain the two types of pipeline used in jenkins along with the syntax and so a scripted pipeline is based on groovyscript as their domain specific language for jenkins and there are one or more note blocks that are used throughout the entire pipeline on the left hand side you can actually see what the actual script would look like and the right hand side shows what the actual declaration for each section of that script would be the second type of jenkins pipeline is a declarative pipeline and a declarative pipeline provides a simple and a friendly syntax to define what the pipeline should look like and then you can actually at this point use an example to actually break out how blocks are used to find the work completed in a decorative pipeline so how do you create a copy and backup of jenkins well to create a backup periodically back up jenkins to your jenkins home directory and then create a copy of that directory it's really as simple as that the question you'll be asked as well is how can you copy jenkins from one server to another well there essentially there are three ways to do that one is you can move a job from one installation of jenkins to another by copying the corresponding job directory the second would be to create a copy of an existing job directory and making a clone of that job directory but with a different name and the third is to rename an existing job by renaming a directory so security is fundamental to all the work that we do within devops and jenkins provides the center core to all the work that gets completed within a devops environment there are three ways in which you can apply security to authenticate users effectively and when you're asked about this question of security within jenkins the three responses you want to be able to provide is a jenkins has its own internal database that uses secured user data from and user credentials b is you can use a ldap or lightweight directory access protocol server to be able to authenticate jenkins users or c you can actually configure jenkins to authenticate by using such as oauth which is a more modern method of being able to authenticate users you're going to be asked how to deploy a custom build of a core plugin within jenkins and essentially the four steps you want to go through are first of all copying the hpi plugin file into the jenkins home plugins subdirectory you want to remove the plugins development directory if there is one you want to create an empty file called plugin.hpi.pinned and once you've completed these three steps restart jenkins and your custom build plugin should be available how can you temporarily turn off jenkins security if the administrative user has locked themselves out of the admin console this doesn't happen very often but when it does it's good to know how you can actually get into jenkins and be able to resolve the problems of authenticating effectively into the system as an administrator so when you want to be able to get into a jenkins environment what you want to be able to do is locate the config file you should see that it's set to true which allows for security to be enabled if you then change the user security setting to false security will disabled allow you to make your administrative changes and will not be re-enabled until the next time jenkins is restarted so what are the ways in which a build can be scheduled and run in jenkins well there are four ways in which you can identify the way a build can be scheduled on running jenkins the first is when source code management commits new code into the repository you can run jenkins at that point the second can be the after the completion of other builds so maybe you have multiple builds in your project that are dependent to each other and when so many other builds have been executed then you can have jenkins run you can schedule build to run at a specified time so you may have nightly builds of your code that illustrates the changes in the solution you're building and then finally you also can manually build a environment on request occasionally you will want to also restart jenkins and so it's good that when a question around how do you restart jenkins manually comes up that you have the answers and there are two ways in which you can do it one is you can force a restart without waiting for bills to complete by using the jenkins url that you have for your environment slash restart or you can allow all running bills to complete before restart are required in which case you would use the command of the url for your jenkins environment slash safe restart i hope this helps you in your interview with that we have reached the end of this complete jenkins tutorial i hope you enjoyed this video do like and share it thank you for watching and stay tuned for more from simply learn [Music]
Info
Channel: Simplilearn
Views: 1,275,174
Rating: undefined out of 5
Keywords: jenkins full tutorial, jenkins tutorial for beginners, jenkins tutorial, jenkins pipeline, jenkins pipeline tutorial, jenkins complete tutorial, jenkins crash course, what is jenkins, what is jenkins and how it works, jenkins in devops, jenkins installation in windows, learn jenkins, learn jenkins from scratch, learn jenkins pipeline, jenkins continuous integration tutorial, jenkins configuration, jenkins ci cd tutorial, jenkins, devops, simplilearn devops, simplilearn
Id: FX322RVNGj4
Channel Id: undefined
Length: 176min 6sec (10566 seconds)
Published: Mon Nov 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.