Jenkins Essentials - Second Edition

4 (1 reviews total)
By Mitesh Soni
    Advance your knowledge in tech with a Packt subscription

  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Exploring Jenkins

About this book

In agile development practices, developers need to integrate their work frequently to fix bugs or to create a new feature or functionality. Jenkins is used specifically for Continuous Integration, helping to enforce the principles of agile development. This book focuses on the latest and stable release of Jenkins (2.5 and later), featuring the latest features, such as Pipeline as Code, the new setup experience, and the improved UI. With the all-new Pipeline as Code feature, you will be able to build simple or advanced pipelines easily and rapidly, hence improving your teams' productivity.

This book begins by tackling the installation of the necessary software dependencies and libraries you'll need to perform Continuous Integration for a Java application. From there, you'll integrate code repositories, applications, and build tools for the implementation of Continuous Integration.

Finally, you will also learn how to automate your deployment on cloud platforms such as AWS and Microsoft Azure, along with a few advanced testing techniques.

Publication date:
June 2017


Chapter 1. Exploring Jenkins

Jenkins is an open source automation server (after Jenkins 2.0 was released) written in Java. It was one of the most popular Continuous Integration (CI) tools used to build and test different kinds of projects. Now, it is also used for Continuous Delivery (CD) after Jenkins 2.0. This chapter describes in detail the basics of CI and overview of Jenkins 2. It describes the importance of CI and CD as a practice to cultivate DevOps culture in recent times.

This chapter also describes installation and configuration of Jenkins 2. We are going to take a jumpstart tour through some of the key features of Jenkins and plugin installations as well.

To be precise, we will discuss the following topics in this chapter:

  • Introduction of Jenkins 2 and its features
  • Installation of Jenkins 2
  • Jumpstart tour of Jenkins dashboard
  • Configuration settings in Jenkins
  • Overview of CICD pipeline

Lets get started! On your marks, get set, go!

In this chapter, we will see what Jenkins 2 is and the new features introduced regarding CI as a part of our DevOps journey. We will cover the following steps to complete our DevOps journey. Each chapter is a stepping stone to reach the next one. It is always good to have an incremental approach so we can measure our success and feel the pain points as well to realize the value of this journey:

At the end of this chapter, we will know essential things about Jenkins 2 and how it is a game changer in terms of CD. It is no longer a CI server. It is on its way to becoming a mature product in the category of automation servers by focusing on Continuous Delivery after Jenkins 2.0 is released.


Introduction of Jenkins 2

Let's first understand what CI is. CI is one of the most popular application development practices in recent times. Developers integrate bug fixes, new feature development, or innovative functionality in a code repository. The CI tool verifies the integration process with an automated build and test to detect issues with current sources of an application and provide quick feedback:

Jenkins is a simple, extensible, and user friendly open source tool that provides continuous integration services for application development. Jenkins supports SCM tools such as Git, Subversion, Star Team, and CVS, AccuRev. Jenkins can build Apache Ant and Apache Maven-based projects.

The concept of plugins makes Jenkins more attractive, easy to learn, and easy to use. There are various categories of plugins available, such as the following:

  • Source code management
  • Slave launchers and controllers
  • Build triggers
  • Build tools
  • Build notifiers
  • Build reports
  • Other post-build actions
  • External site/tool integrations
  • UI plugins
  • Authentication and user management
  • Android development
  • iOS development
  • .NET development
  • Ruby development
  • Library plugins

Jenkins defines interfaces or abstract classes that model a facet of a build system. Interfaces or abstract classes agree on what needs to be implemented, and Jenkins uses plugins to extend those implementations.

With Jenkins 2, the focus is also on CD where the application is deployed in the specific environment using an automated approach. Jenkins 2 is a clear signal regarding the focus on both CI and CD best practices of DevOps culture and not on CI only.


Jenkins is one of the most popular automation servers in the market, and the reasons for its popularity are some of the following features:

  • Easy installation on different operating systems, Arch Linux, FreeBSD, Gentoo, MacOS X, openBSD, openSUSE, RedHAT/Fedora/CentOS, Ubuntu/Debian, Windows, and it is also available for Docker and as generic Java packages too.
  • Easy upgrades: Jenkins has very speedy release cycles (long-term support and weekly releases).
  • Simple and easy to use user interface in Jenkins 2.x -.
  • Set of suggested plugins at the time of installation.
  • Improved new item page.
  • Improved job configuration page with easy navigation.
  • Jenkins 2 supports pipelines as code that uses domain-specific language (DSL) to model application delivery pipelines as code; we can utilize the pipelines as code and keep them in a repository and maintain versions in a similar way to source code.
  • Easily extensible with the use of third-party plugins: there are over 400 plugins.
  • Easy to configure the setup environment in the user interface. It is also possible to customize user interface as you wish.
  • Master slave architecture supports distributed builds to reduce the load on CI servers.
  • Build scheduling based on cron expressions.
  • Shell and Windows command execution that makes any command-line tool integration in the pipeline very easy.
  • Notification support related to build status.

Installation of Jenkins 2

Let's start with Jenkins 2.x installation. Go to and click on the Download button to download packages for installation of Jenkins:

At, we get two sections. One is for Long-term Support (LTS) that is selected after every 12 weeks from regular releases as the stable release from that duration.

Another section is Weekly release, which has bug fixes and is made available to users and developers.

We will use the Generic Java Package (.war) file in our installation of Jenkins as shown in the following screenshot.

The reason for selecting the .war file for the Jenkins installation is its ease of use across operating systems. Jenkins is written in Java, and in any case, to execute Jenkins we need the latest Java version installed on our system. For Jenkins Installation, Java 8 is recommended. It is recommended to have 1-GB of memory.

Verify the Java installation by using the java -version command in the command prompt or terminal based on the operating system.

Download Generic Java Package (.war) from on the local system as follows:

Before we start Jenkins, we will set the JENKINS_HOME environment variable. When we install and configure Jenkins, all the files reside in the jenkins directory by default. We often need to change the default location for our convenience. We can do that by setting the JENKINS_HOME environment variable. Follow the following steps:

  1. To set the JENKINS_HOME environment variable in Windows 10, go to Control Panel | All Control Panel Items | System and click on Advanced system settings | Advanced | Environment Variables... Please see the manual for other operating systems to set Environment Variables...:
  1. Click on New. Enter the variable name and location and click OK:
  1. Now our JENKINS_HOME is set so Jenkins will use that directory to store all configuration files.
  2. Open the command prompt or terminal (depending on your operating system) and execute the following command:
Java -jar Jenkins.war
  1. This is a fresh installation of Jenkins, so initial setup is required. Note the password:
  1. Once Jenkins is fully up and running, visit http://localhost:8080 and it will open the Getting Started page to Unlock Jenkins. Give the password we copied from the terminal or go to the location given in the dialog box. Copy the password from there and click on Continue:
  1. Click on Install to see the suggested plugins. If we are behind the proxy, then another dialog box will pop up before this page to provide proxy details:
  1. Wait while all the plugins are installed properly:
  1. Verify the green tick boxes for all the plugins that have been installed successfully:
  1. Once all plugins are installed successfully, create the first admin user and click on Save and Finish:
  1. Click on Start using Jenkins:

In the next section, we will see details of the Jenkins dashboard.


Jumpstart tour of the Jenkins dashboard

The Jenkins dashboard is the place where all the operations related to CI and CD can be managed:

Click on the Manage Jenkins link on the Jenkins dashboard. Here, we can configure Jenkins, Security, Global Tools, Plugins, Users, and more:

Click on Manage Plugins. You will see the following tabs:

  • The Updates tab provides details on updates available on the installed plugins.
  • The Available tab provides a list of plugins that are not installed yet.
  • The Installed tab provides a list of plugins that are already installed.
  • The Advanced tab contains sections to configure proxies so we can download plugins even after we are behind the proxy. It also provides sections to upload HPI files for plugins in case we have already downloaded the plugin from the internet:

In the Manage Jenkins section, click on Manage Nodes.

By default, the system on which Jenkins is installed is a master node. This is the section that can be utilized to create the master agent architecture that we will cover later in the book:

In the next section, we will cover different kinds of configuration available in the Manage Jenkins section.


Configuration settings in Jenkins

In Manage Jenkins, click on the Configure System link.

Here, we can get information about the JENKINS_HOME directory, the workspace root directory, and so on. We can set the Jenkins URL as well in this section:

In Manage Jenkins, click on Configure Global Security to see the security settings available in Jenkins. We will cover role-based access, matrix-based project security, and other features in later parts of this book:

In Manage Jenkins, click on the Global Tool Configuration link to provide details related to all tools available on the system that can be utilized to perform certain tasks. Depending on plugins related to specific tools, that section will appear on this page.

Another important thing to mention is that we can configure multiple versions of the same tool. For example, we can configure Java 6, Java 7, and Java 8. It is highly likely that different projects require different versions of Java for their execution. In such cases, we can configure multiple JDKs here and utilize specific JDKs in specific build jobs:

As discussed earlier in this chapter, the Manage Plugins section has an Advanced tab that allows us to configure proxy details.

This was all about the basic installation and configuration of Jenkins 2.x, and now we will cover what we are going to achieve in this book.


Overview of the CI/CD pipeline

The application development life cycle is traditionally a lengthy manual process. In addition, it requires effective collaboration between development and operations teams. The CI/CD pipeline is a demonstration of automation involved in the application development lifecycle that contains automated build execution, automated test execution, notifications to stakeholders, and deployment in different runtime environments. Effectively, a deployment pipeline is a combination of continuous integration and continuous delivery, and hence a part of DevOps practices. The following figure depicts the pipeline process. Depending on the culture of organization and the available tools, the flow and tools may differ:

Members of the development team check code into a source code repository. Continuous integration products such as Jenkins are configured to poll changes from the code repository. Changes in the repository are downloaded to the local workspace and Jenkins triggers a build process that is assisted by Ant or Maven or Gradle or any build script. Automated test execution, unit testing, static code analysis, reporting, and notification of successful or failed build processes are also parts of the Continuous Integration process.

Once the build is successful, it can be deployed to different runtime environments such as testing, pre-production, production, and so on. Deploying a WAR file in terms of a JEE application is normally the final stage in the deployment pipeline. However, after the deployment of this package into a pre-production environment, functional and security testing can be performed.

One of the biggest benefits of the pipeline is a faster feedback cycle. Identification of issues in the application in early stages and no dependency on manual effort make this entire end-to-end process more effective.

In the following chapters, we will see how Jenkins can be used to implement CI and CD practices in modernizing the culture of an organization.



Congratulations! We have reached the end of this chapter. So far, we have covered the basics of CI and have introduced Jenkins and its features. We have also completed the installation of Jenkins using generic package files. We also completed a quick tour of features available in the Jenkins dashboard. In addition to this, we have discussed the CI/CD pipeline and its importance in cultivating DevOps culture.

Now that we are able to use our automation server, Jenkins, we can begin creating a job and verify how Jenkins works. Before that, we will see how different configurations can be done in Jenkins in the next chapter.

About the Author

  • Mitesh Soni

    Mitesh Soni is a DevOps enthusiast. He has worked on projects for DevOps enablement using Microsoft Azure and Visual Studio Team Services. He also has experience of working with other DevOps-enabling tools, such as Jenkins, Chef, IBM UrbanCode Deploy, and Atlassian Bamboo.

    He is a CSM, SCJP, SCWCD, VCP, IBM Bluemix, and IBM Urbancode certified professional.

    Browse publications by this author

Latest Reviews

(1 reviews total)
Bons exemplos práticos de ci
Jenkins Essentials - Second Edition
Unlock this book and the full library for FREE
Start free trial