Jenkins Essentials

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. To integrate all work efficiently and verify it is an error-prone and time-consuming manual task. Jenkins is used specifically for continuous integration, helping to enforce the principles of agile development.

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'll explore the automated deployment of an application in Tomcat, along with details on managing and configuring Jenkins based on your requirements by using plugins.

Publication date:
July 2015
Publisher
Packt
Pages
186
ISBN
9781783553471

 

Chapter 1. Exploring Jenkins

 

"Continuous effort—not strength or intelligence—is the key to unlocking our potential."

 
 --Winston Churchill

Jenkins is an open source application written in Java. It is one of the most popular continuous integration (CI) tools used to build and test different kinds of projects. In this chapter, we will have a quick overview of Jenkins, essential features, and its impact on DevOps culture. Before we can start using Jenkins, we need to install it. In this chapter, we have provided a step-by-step guide to install Jenkins. Installing Jenkins is a very easy task and is different from the OS flavors.

We will also learn the basic configuration of Jenkins. We will take a quick tour of some key sections of the Jenkins UI and plugin installations as well. This chapter will also cover the DevOps pipeline and how the rest of the chapters will cover implementing it.

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

  • Introduction to Jenkins and its features

  • Installation of Jenkins on Windows and the CentOS operating system

  • A jump-start tour of the Jenkins dashboard

  • How to change configuration settings in Jenkins

  • What is the deployment pipeline

On your mark, get set, go!

 

Introduction to Jenkins and its features


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

Jenkins is a simple, extensible, and user-friendly open source tool that provides CI services for application development. Jenkins supports SCM tools such as StarTeam, Subversion, CVS, Git, AccuRev and so on. Jenkins can build Freestyle, 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 Source code management, Slave launchers and controllers, Build triggers, Build tools, Build notifies, 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, and so on.

Jenkins defines interfaces or abstract classes that model a facet of a build system. Interfaces or abstract classes define an agreement on what needs to be implemented; Jenkins uses plugins to extend those implementations.

Note

To learn more about all plugins, visit https://wiki.jenkins-ci.org/x/GIAL.

To learn how to create a new plugin, visit https://wiki.jenkins-ci.org/x/TYAL.

To download different versions of plugins, visit https://updates.jenkins-ci.org/download/plugins/.

Features

Jenkins is one of the most popular CI servers in the market. The reasons for its popularity are as follows:

  • Easy installation on different operating systems.

  • Easy upgrades—Jenkins has very speedy release cycles.

  • Simple and easy-to-use user interface.

  • Easily extensible with the use of third-party plugins—over 400 plugins.

  • Easy to configure the setup environment in the user interface. It is also possible to customize the user interface based on likings.

  • The master slave architecture supports distributed builds to reduce loads on the CI server.

  • Jenkins is available with test harness built around JUnit; test results are available in graphical and tabular forms.

  • Build scheduling based on the cron expression (to know more about cron, visit http://en.wikipedia.org/wiki/Cron).

  • Shell and Windows command execution in prebuild steps.

  • Notification support related to the build status.

 

Installation of Jenkins on Windows and CentOS


  1. Go to https://jenkins-ci.org/. Find the Download Jenkins section on the home page of Jenkins's website.

  2. Download the war file or native packages based on your operating system. A Java installation is needed to run Jenkins.

  3. Install Java based on your operating system and set the JAVA_HOME environment variable accordingly.

Installing Jenkins on Windows

  1. Select the native package available for Windows. It will download jenkins-1.xxx.zip. In our case, it will download jenkins-1.606.zip. Extract it and you will get setup.exe and jenkins-1.606.msi files.

  2. Click on setup.exe and perform the following steps in sequence. On the welcome screen, click Next:

  3. Select the destination folder and click on Next.

  4. Click on Install to begin installation. Please wait while the Setup Wizard installs Jenkins.

  5. Once the Jenkins installation is completed, click on the Finish button.

  6. Verify the Jenkins installation on the Windows machine by opening URL http://<ip_address>:8080 on the system where you have installed Jenkins.

Installation of Jenkins on CentOS

  1. To install Jenkins on CentOS, download the Jenkins repository definition to your local system at /etc/yum.repos.d/ and import the key.

  2. Use the wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo command to download repo.

  3. Now, run yum install Jenkins; it will resolve dependencies and prompt for installation.

  4. Reply with y and it will download the required package to install Jenkins on CentOS. Verify the Jenkins status by issuing the service jenkins status command. Initially, it will be stopped. Start Jenkins by executing service jenkins start in the terminal.

  5. Verify the Jenkins installation on the CentOS machine by opening the URL http://<ip_address>:8080 on the system where you have installed Jenkins.

Installation of Jenkins as a web application

  1. Download Java Web Archive (.war) (latest and greatest (1.606)) from http://jenkins-ci.org/.

  2. Copy jenkins.war into your virtual or physical machine. Open Command Prompt or a terminal based on the operation system. In our case, we will copy it into a directory of a CentOS virtual machine.

  3. Open Command Prompt and execute the java –jar Jenkins.war command. Verify the Jenkins installation on the system by opening the http://<ip_address>:8080 URL on the system where you have installed Jenkins.

 

A jump-start tour of the Jenkins dashboard


  1. On the Jenkins dashboard, click on Create new jobs or on New Item to create Freestyle- or Maven-based projects for CI.

  2. To verify system properties, visit http://<ip_address>:8080/systeminfo or click on Manage Jenkins, and then click on System Information to get environmental information to assist troubleshooting.

 

How to change configuration settings in Jenkins


  1. Click on the Manage Jenkins link on the dashboard to configure system, security, to manage plugins, slave nodes, credentials, and so on.

  2. Click on the Configure System link to configure Java, Ant, Maven, and other third-party products' related information.

  3. Jenkins uses Groovy as its scripting language. To execute the arbitrary script for administration/trouble-shooting/diagnostics on the Jenkins dashboard, go to the Manage Jenkins link on the dashboard, click on Script Console, and run println(Jenkins.instance.pluginManager.plugins).

  4. To verify the system log, go to the Manage Jenkins link on the dashboard and click on the System Log link or visit http://localhost:8080/log/all.

  5. To get more information on third-party libraries—version and license information in Jenkins, go to the Manage Jenkins link on the dashboard and click on the About Jenkins link.

 

What is the deployment pipeline?


The application development life cycle is a traditionally lengthy and a manual process. In addition, it requires effective collaboration between development and operations teams. The deployment pipeline is a demonstration of automation involved in the application development life cycle containing the automated build execution and test execution, notification to the stakeholder, and deployment in different runtime environments. Effectively, the deployment pipeline is a combination of CI and continuous delivery, and hence is a part of DevOps practices. The following diagram depicts the deployment pipeline process:

Members of the development team check code into a source code repository. CI 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 an automated build process, which is assisted by Ant or Maven. Automated test execution or unit testing, static code analysis, reporting, and notification of successful or failed build process are also part of the CI process.

Once the build is successful, it can be deployed to different runtime environments such as testing, preproduction, production, and so on. Deploying a war file in terms of the JEE application is normally the final stage in the deployment pipeline.

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

In the next chapters, we will see how Jenkins can be used for implementing CI practices in modernizing IT.

 

Self-test questions


Q1. What is Jenkins?

  1. A continuous integration product

  2. A continuous delivery product

Q2. What makes Jenkins extensible?

  1. Plugins

  2. Open Source Distribution

Q3. Which command is used to run the Jenkins installation file in the war format?

  1. java –jar Jenkins.war

  2. java –j Jenkins.war

Q4. How do we get system information on the Jenkins dashboard?

  1. Visit http://<ip_address>:8080/manage

  2. Visit http://<ip_address>:8080/systeminfo

Q5. How do we change global settings for configuration on the Jenkins dashboard?

  1. Click on the Manage Jenkins link on the dashboard

  2. Click on the Credentials link on the dashboard

Q6. What is the deployment pipeline?

  1. Continuous Integration Practices

  2. Continuous Delivery Practices

  3. Demonstration of automation involved in the application development life cycle

  4. None of the above

Q7. Explain the benefits of the deployment pipeline?

  1. Faster feedback cycle

  2. Identification of issues in an application at early stages

  3. No dependencies on manual efforts

  4. All of the above

 

Summary


Congratulations! We reached the end of this chapter and hence we have Jenkins installed on our physical or virtual machine, and you are ready to go to the next chapter. Till now, we covered the basics of CI and the introduction to Jenkins and its features. We completed the installation of Jenkins on Windows and CentOS platforms. We also completed a quick tour of features available in Jenkins's dashboard. In addition to this, we discussed the deployment pipeline and its importance in CI.

Now that we are able to use our CI server, Jenkins, we can begin creating a job and verify how Jenkins works.

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
Jenkins Essentials
Unlock this book and the full library for $5 a month*
Start now