What Is Jenkins? What are its Use-Cases

Aravind Menon
4 min readMar 12, 2021

Jenkins is an open-source server that is written entirely in Java. It lets you execute a series of actions to achieve the continuous integration process, that too in an automated fashion.

This CI server runs in servlet containers such as Apache Tomcat. Jenkins facilitates continuous integration and continuous delivery in software projects by automating parts related to build, test, and deployment. This makes it easy for developers to continuously work on the betterment of the product by integrating changes to the project.

Features Of Jenkins

1. Easy Installation & Configuration

It is available for almost all the popular operating systems such as Windows, different flavors of Unix, and Mac OS.

2. Open-Source

As it is open-source, it is free for use. There is a strong involvement of the community which makes it a powerful CI/CD tool.

3. Easy Distribution

Jenkins is designed in such a manner that makes it relatively easy to distribute work across multiple machines and platforms for accelerated build, testing, and deployment.

What can Jenkins do?

  • Automation testing using test frameworks such as Nose2, PyTest, Robot, Selenium, and more.
  • Execute test scripts (using Windows terminal, Linux shell)
  • Achieve test results and perform post actions such as printing test reports, and more.
  • Execute test scenarios against different input combinations for obtaining improved test coverage.

Architecture Of Jenkins

  • Developers make the required modifications in the source code and commit the changes to the repository. A new version of the file is created in the version control system.
  • The repository is continuously checked by Jenkins CI server for any changes.
  • The Build server performs a build with the code and an executable is generated if the build process is successful. In case of a build failure, an automated email with a link to build logs and other build artifacts is sent to the developer.
  • In case of a successful build, the built application (or executable) is deployed to the test server.

Jenkins and its Use-Cases

Bitbucket Server

  • Bitbucket Server is a Git repository management solution designed for professional teams. It’s part of the Atlassian product family along with Jira, Confluence, and many more tools designed to help teams unleash their full potential.
  • To integrate it with Jenkins, you can install the Bitbucket Server integration for Jenkins plugin.

Jenkins and Python

  • In the Python ecosystem there are tools which can be integrated into Jenkins for testing/reporting such as nose2 and pytest for executing unit tests and generating JUnit-compatible XML test reports.
  • pylint for generating code quality reports which can be integrated directly into Jenkins for trending and reporting purposes.

JenkinsAPI

  • The JenkinsAPI makes Jenkins easier to use by providing an easy to use conventional python interface.
  • This library wraps up that interface as more conventional python objects in order to make most Jenkins oriented tasks simpler.

Using the API, we can perform the following tasks:

  • Query the test-results of a completed build.
  • Get a objects representing the latest builds of a job.
  • Block until jobs are complete.
  • Username and password authentication support for Jenkins instances with authentication turned on.
  • Add, remove and query Jenkins slaves.

Pipeline as Code with Jenkins

Using a pipeline, users can implement a project’s entire build/test/deploy pipeline in a Jenkinsfile and store that alongside their code, treating their pipeline as another piece of code checked into source control.

Defining a Pipeline

A Pipeline can be created in one of the following ways:

  • Through Blue Ocean — after setting up a Pipeline project in Blue Ocean, the Blue Ocean UI helps you write your Pipeline’s Jenkinsfile and commit it to source control.
  • Through the classic UI — you can enter a basic Pipeline directly in Jenkins through the classic UI.
  • In SCM — you can write a Jenkinsfile manually, which you can commit to your project’s source control repository. [3]

The syntax for defining a Pipeline with either approach is the same, but while Jenkins supports entering Pipeline directly into the classic UI, it is generally considered best practice to define the Pipeline in a Jenkinsfile which Jenkins will then load directly from source control.

Every job in the Jenkins pipeline has some dependency on one or more events. Continuous delivery pipeline in Jenkins consists of four states — Build, Deploy, Test, and Release. Each of these states consist of events that execute in a sequence.

What Is a Jenkinsfile?

The entire definition of a Jenkins Pipeline is written into a text file called Jenkinsfile. It contains the steps required for running a Jenkins Pipeline.

Jenkinsfile can also be committed to the source control repository of the project. With Jenkinsfile, the CD Pipeline is also treated as a part of the application that is versioned, committed, and reviewed like any other piece of code.

Some of the major benefits of Jenkinsfile are:

  • Single Jenkinsfile can be used for creating a Pipeline build process for all the branches and executing pull requests.
  • The implementation in a Pipeline can be reviewed like normal source code.
  • Audit trail of the Pipeline.
  • Singular source for the Pipeline can be viewed as well as edited by multiple members associated with the project.

--

--