DevOps Certification Training
- 47k Enrolled Learners
- Live Class
Jenkins is one of the most important tools in DevOps. I hope you have read my previous blog on What is Jenkins. In this Jenkins Tutorial blog, I will focus on Jenkins architecture and Jenkins build pipeline along with that I will show you how to create a build in Jenkins.
Before we proceed with Jenkins Tutorial, the key takeaways from the previous blog are:
Now is the correct time to understand Jenkins architecture.
Let us revise the standalone Jenkins architecture that I have explained to you in the previous blog, below diagram depicts the same.
This single Jenkins server was not enough to meet certain requirements like:
To address the above stated needs, Jenkins distributed architecture was introduced.
Jenkins uses a Master-Slave architecture to manage distributed builds. In this architecture, Master and Slave communicate through TCP/IP protocol.
Your main Jenkins server is the Master. The Master’s job is to handle:
A Slave is a Java executable that runs on a remote machine. Following are the characteristics of Jenkins Slaves:
The diagram below is self explanatory. It consists of a Jenkins Master which is managing three Jenkins Slave.
Now let us look at an example in which Jenkins is used for testing in different environments like: Ubuntu, MAC, Windows etc.
The diagram below represents the same:
The following functions are performed in the above image:
It is used to know which task Jenkins is currently executing. Often several different changes are made by several developers at once, so it is useful to know which change is getting tested or which change is sitting in the queue or which build is broken. This is where pipeline comes into picture. The Jenkins Pipeline gives you an overview of where tests are up to. In build pipeline the build as a whole is broken down into sections, such as the unit test, acceptance test, packaging, reporting and deployment phases. The pipeline phases can be executed in series or parallel, and if one phase is successful, it automatically moves on to the next phase (hence the relevance of the name “pipeline”).The below image shows how a multiple build Pipeline looks like.
Hope you have understood the theoretical concepts. Now, let’s have some fun with hands-on.
I will create a new job in Jenkins, it is a Freestyle Project. However, there are 3 more options available. Let us look at the types of build jobs available in Jenkins.
Freestyle build jobs are general-purpose build jobs, which provides maximum flexibility. The freestyle build job is the most flexible and configurable option, and can be used for any type of project. It is relatively straightforward to set up, and many of the options we configure here also appear in other build jobs.
The “multiconfiguration project” (also referred to as a “matrix project”) allows you run the same build job on different environments. It is used for testing an application in different environments, with different databases, or even on different build machines.
Monitor an External Job:
The “Monitor an external job” build job lets you keep an eye on non-interactive processes, such as cron jobs.
The “maven2/3 project” is a build job specially adapted to Maven projects. Jenkins understands Maven pom files and project structures, and can use the information gleaned from the pom file to reduce the work you need to do to set up your project.
Here is a video on Jenkins tutorial for better understanding of Jenkins. Check out this Jenkins tutorial video.
Step 1: From the Jenkins interface home, select New Item.
Step 2: Enter a name and select Freestyle project.
Step 3: This next page is where you specify the job configuration. As you’ll quickly observe, there are a number of settings available when you create a new project. On this configuration page, you also have the option to Add build step to perform extra actions like running scripts. I will execute a shell script.
This will provide you with a text box in which you can add whatever commands you need. You can use scripts to run various tasks like server maintenance, version control, reading system settings, etc. I will use this section to run a simple script.
Step 4: Save the project, and you’ll be taken to a project overview page. Here you can see information about the project, including its built history.
Step 5: Click Build Now on the left-hand side to start the build.
Step 6: To see more information, click on that build in the build history area, whereupon you’ll be taken to a page with an overview of the build information.
Step 7: The Console Output link on this page is especially useful for examining the results of the job in detail.
Step 8: If you go back to Jenkins home, you’ll see an overview of all projects and their information, including status.
Status of the build is indicated in two ways, by a weather icon and by a colored ball. The weather icon is particularly helpful as it shows you a record of multiple builds in one image.
As you can see in the above image, the sun represents that all of my builds were successful. The color of the ball gives us the status of that particular build, in the above image the color of the ball is blue which means that this particular build was successful.
In this Jenkins Tutorial, I have just given an introductory example. In my next blog, I will show you how to pull and build code from the GitHub repository using Jenkins.
If you found this Jenkins Tutorial relevant, check out the DevOps training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. The Edureka DevOps Certification Training course helps learners gain expertise in various DevOps processes and tools such as Puppet, Jenkins, Nagios and GIT for automating multiple steps in SDLC.
Got a question for us? Please mention it in the comments section and we will get back to you.