Simplifying Continuous Integration: A Comprehensive Guide to Installing Jenkins 2 on CentOS


Brief Overview of Continuous Integration and Its Importance in Software Development

Continuous Integration (CI) is the practice of integrating code changes frequently into a shared repository. The objective is to detect and fix integration problems as early as possible.

By doing so, developers can significantly reduce the time spent debugging issues that crop up when software components are combined. CI has become a crucial aspect of modern software development workflows, particularly in Agile or DevOps environments.

It enables teams to deliver high-quality software quickly by automating build processes, running automated tests, and continuously monitoring for issues. Implementing CI practices also leads to improved collaboration among team members by promoting transparency and ensuring everyone works from the same baseline code.

Explanation of Jenkins and Its Role in Continuous Integration

Jenkins is an open-source automation server widely used for building, testing, and deploying code changes continuously. It’s one of the most popular CI tools available today due to its flexibility and ease-of-use.

Jenkins operates on a client-server model with a web-based interface that allows developers to create complex pipelines for their projects easily. Each pipeline consists of several jobs that perform specific tasks such as building code changes or running automated tests.

The primary advantage of using Jenkins over other CI tools is its extensibility through plugins. With over 1500 plugins available at the time of writing this article, it’s easy to integrate Jenkins with other tools like version control systems (Git), build management (Maven), deployment servers (Docker), or testing frameworks (Selenium).

Preparing the Environment

Choosing the Right Operating System for Jenkins Installation (CentOS)

When it comes to installing Jenkins on a server, there are many choices available. However, CentOS is one of the most recommended operating systems for installing Jenkins due to its stability and security.

CentOS is a free and open-source operating system that is widely used in enterprise-level applications. It also has long-term support (LTS) releases, which means that updates will be provided for a longer duration of time than other Linux distributions.

Setting Up a Virtual Machine or Dedicated Server for Jenkins

Once you have chosen your operating system, you need to decide if you will be using a virtual machine or a dedicated server for Jenkins. A virtual machine allows multiple operating systems to run on one physical machine, while a dedicated server is an entire physical machine dedicated solely to hosting Jenkins. Using a virtual machine provides more flexibility as you can create multiple instances of CentOS running on the same hardware.

This means that you can isolate different projects and testing environments without having to purchase additional hardware. However, if you have large-scale testing requirements and want more control over your environment, then using a dedicated server might be the better choice.

Installing Necessary Dependencies (Java, Git, etc.)

Before installing Jenkins 2 on CentOS, it’s essential to ensure that all necessary dependencies are installed. The most critical dependencies include Java and Git.

Java is required because Jenkins runs on top of it while Git is needed for version control integration. To install Java on CentOS, simply use Yum package manager: sudo yum install java-1.8.0-openjdk

To install Git: sudo yum install git Other useful dependencies include Maven (build tool), Gradle (build automation tool), Ant (Java build automation tool), Docker Engine (containerization platform), etc.

Installing Jenkins 2 on CentOS

Downloading and Configuring the Jenkins Repository

Before installing Jenkins on CentOS, it is important to first download and configure the Jenkins repository. The following steps will guide you through the process: 1. Navigate to the official Jenkins website at and download the stable release of Jenkins for your platform.

2. Once you have downloaded the necessary files, create a new repository directory for your Jenkins installation using this command: mkdir /etc/yum.repos.d/jenkins.repo

3. Next, navigate to this directory using this command: cd /etc/yum.repos.d/

4. Use a text editor such as nano or vim to create a new .repo file in this directory with the following contents: [jenkins]

name=Jenkins baseurl=

gpgcheck=1 5. Save and close this file.

Installing Jenkins Using Yum Package Manager

Once you have downloaded and configured the Jenkins repository, it is time to install Jenkins on your CentOS machine using yum package manager. 1. Run an update of all packages on your system by running this command: sudo yum update

2. Then, run this command to install jenkins along with all dependencies: sudo yum install jenkins

3. After installation is complete, start jenkins service by typing: sudo systemctl start jenkins.service

sudo systemctl enable jenkins.service Now that we have successfully installed Jenkins on our CentOS machine, let’s move onto configuring firewall settings.

Configuring Firewall Settings To Allow Access To Jenkins

In order for other machines to access our newly installed instance of Jenkins, we must configure our firewall settings appropriately. 1. Firstly, check if firewalld service is running:

sudo systemctl status firewalld 2. If the firewall service is not running, enable and start it by running the following commands:

sudo systemctl enable firewalld sudo systemctl start firewalld

3. Once the firewall service is running, we can add a rule to allow access to Jenkins by typing: sudo firewall-cmd –zone=public –permanent –add-port=8080/tcp

4. Reload the firewall rules for changes to take effect, using this command: sudo firewall-cmd –reload

With these steps complete, you should now be able to access your Jenkins instance using a web browser at http://your_server_ip_address:8080/ or http://your_server_domain_name:8080/. You should also be able to configure and manage your Jenkins instance from another machine on the same network or even over the internet with proper routing configuration in place.

Setting Up Jobs and Pipelines in Jenkins

Creating a New Job in Jenkins

After successfully installing Jenkins on your CentOS machine, the next step is to create a new job. A job is essentially a task that you want Jenkins to automate, such as building a project or running tests. To create a new job, you will need to navigate to the Jenkins dashboard and click on “New Item”.

This will take you to the “Create New Job” page where you can specify the details of the job. There are several types of jobs that you can create in Jenkins, such as freestyle projects, pipeline projects, or multi-configuration projects.

For beginners, we recommend starting with freestyle projects as they are simpler and easier to set up. Once you have selected the type of project you want to create, give it a meaningful name and select “OK” at the bottom of the page.

Configuring Job Parameters and Triggers

Now that your job has been created, it’s time to configure its parameters and triggers. Parameters allow you to customize how your job runs by letting you pass in values at runtime.

For example, if your job builds different versions of your codebase for different environments (such as staging vs production), you can use parameters like environment variables or command line arguments. Triggers determine when your job should be run.

There are several types of triggers available in Jenkins such as building periodically (e.g., every hour), building when changes are pushed to version control (e.g., Git), or building manually by clicking a button on the Jenkins dashboard. Once you have configured both parameters and triggers for your job according to its needs, save all settings by clicking “Save” at the bottom of the page.

Creating a Pipeline for Automated Testing and Deployment

Pipelines are an advanced feature in Jenkins that allow you to automate complex tasks by creating a series of interconnected jobs. Pipelines have several advantages over traditional jobs as they can be easily visualized, maintained, and managed as code. To create a pipeline in Jenkins, navigate to the “New Item” page and select “Pipeline” as the type of project.

Once you have created a pipeline project, you can define its stages and steps using the Jenkinsfile. The Jenkinsfile is a text file written in Groovy syntax that defines your pipeline’s stages, steps, and other properties.

You can specify how each stage should be run (e.g., build the code, run tests), what happens when a stage fails (e.g., send an email notification), and how artifacts should be published. Setting up jobs and pipelines in Jenkins is an essential step in automating your continuous integration process.

By creating jobs with proper parameters and triggers, you can ensure that your software development process runs smoothly without any manual intervention. And by creating pipelines using Groovy syntax through the Jenkinsfile feature of Jenkins 2 on CentOS machines, you can further simplify complex automation tasks into easy-to-manage code written by developers themselves with visibility for all stakeholders involved with the project remotely or centrally.

Integrating with Other Tools

Integrating with version control systems such as Git or SVN

One of the essential components of continuous integration is having a version control system in place. Git and SVN are popular choices for modern software development.

To integrate Jenkins 2 with either of these tools, we need to install plugins on the Jenkins server. The plugins provide Jenkins with the necessary functionality to interact with the version control system.

For instance, to integrate Jenkins 2 with Git, we need to install Git plugin on the Jenkins server. Once installed, we can configure our jobs and pipelines to pull code from a particular repository using Git commands such as `git clone`.

We can also specify which branch or tag should be used for the build process. Similarly, integrating Jenkins 2 with SVN requires installing SVN plugin on the Jenkins server.

Once installed, developers can check-in their code modifications into a central repository hosted by an SVN server. The pipeline in Jenkins can then be configured to pull this latest code into a build environment using `svn update` command.

Integrating with build tools such as Maven or Gradle

Build tools like Maven and Gradle automate building processes that include compiling source code, running tests and packaging artifacts. Integrating these tools helps achieve more efficient builds that complete successfully without errors. To integrate Maven or Gradle with Jenkins 2, we’ll need to install appropriate plugins on our server that support these build tools.

For example, adding “Maven Integration” plugin allows us use Maven commands inside Jenkins job configurations smoothly. Once configured correctly, Jobs and Pipelines in Jenkins 2 can leverage features provided by these Build Tools – e.g., cleaning up previous builds before starting afresh.

Integrating with testing frameworks such as JUnit or Selenium

Continuous integration often involves running automated tests to catch issues as soon as they occur. Integrating Jenkins 2 with testing frameworks like JUnit or Selenium allows developers to automate tests and run them at every build to ensure the properly functioning software.

JUnit is a popular Java-based testing framework that we can integrate with Jenkins 2 using the “JUnit Plugin”. This plugin will analyze test results and generate reports, which are visible in job run history.

Selenium, on the other hand, is used for functional testing of web applications. We can integrate Selenium Grid with Jenkins 2 to distribute test load across multiple machines, enabling faster and more efficient testing of web applications.

Integrating with these frameworks aids in early bug discovery and reduces time spent on debugging during software development processes. It provides a significant improvement in productivity because developers do not need to execute all the tests manually after each change made in the codebase.

Advanced Configuration Options

Jenkins is an incredibly versatile platform that can be customized to meet the specific needs of your software development team. Here are some advanced configuration options that will help you get the most out of your Jenkins installation.

Customizing the Jenkins User Interface

The default Jenkins user interface is functional but not very aesthetically pleasing. Fortunately, Jenkins provides a number of options for customizing the user interface to suit your preferences. You can add or remove widgets from the dashboard, change the color scheme, and even modify existing CSS stylesheets to completely change the look and feel of Jenkins.

To customize the user interface in Jenkins, navigate to Manage Jenkins > Configure System. This will bring up a page with all of the available configuration options for your installation.

Scroll down to find the User Interface section and select Customize Look and Feel. From here, you can upload custom CSS stylesheets or choose from a number of pre-built themes to apply to your installation.

Configuring Security Settings

Security is a critical concern when it comes to continuous integration systems like Jenkins. Fortunately, Jenkins provides robust security options that allow you to restrict access to certain users or groups based on their roles within your organization. To configure security settings in Jenkins, navigate to Manage Jenkin > Configure Global Security.

From here, you can enable security settings such as LDAP authentication or configure matrix-based security permissions for individual users or groups. You can also configure how users are authenticated and authorized within Jenkins by setting up an authentication provider like Active Directory or OAuth.

Using Plugins

Jenkins has hundreds of plugins available that extend its functionality far beyond its core capabilities. These plugins allow you to integrate with third-party tools like AWS CodeDeploy or SonarQube, add additional build steps or deployment options, and even create custom plugins to meet your specific needs. To browse and install Jenkins plugins, navigate to Manage Jenkins > Manage Plugins.

This will bring up the Plugin Manager, which allows you to browse through available plugins by category or search for specific ones by name. Once you’ve found a plugin you want to install, simply click the Install button and Jenkins will take care of the rest.

By leveraging these advanced configuration options in Jenkins, you can create a powerful continuous integration system that meets the unique needs of your software development team. Whether it’s customizing the user interface, configuring security settings or using plugins to extend functionality, there’s a world of possibilities waiting for you with Jenkins.

Troubleshooting Common Issues

Debugging common issues during installation process

Despite all the preparation and research, sometimes things can go wrong even when following a comprehensive guide like this. The good news is that most installation issues are solvable with a bit of troubleshooting. The first step in debugging any issue is to check logs generated during the installation process.

Jenkins logs are stored in `/var/log/jenkins`. This directory contains various log files such as `jenkins.log` which contain detailed information about what happened during Jenkins startup, shutdown or restart.

A common error message you might encounter is `”Cannot connect to the Docker daemon at unix:///var/run/docker.sock.”` Typically this means that you do not have permission to access the Docker socket. To fix this issue, ensure that your Jenkins user is part of the “docker” group and restart your system.

If you encounter an error while installing plugins, often it’s because network connectivity issues are preventing certain plugins from being downloaded or installed properly. This can be resolved by checking your network configuration settings or temporarily disabling any firewalls which might be blocking certain ports.


Installing Jenkins 2 on CentOS for continuous integration may seem daunting at first but it does not have to be complicated. By following this comprehensive guide, you should now have a deeper understanding of how to prepare the environment for Jenkins, install and configure Jenkins on CentOS, create jobs and pipelines in Jenkins as well as troubleshoot any common issues encountered along the way.

With continuous integration tools like Jenkins 2 becoming more popular among developers worldwide today as a means of streamlining software development cycles and increasing efficiency in project management processes; having a robust and reliable platform for testing code changes becomes even more important than ever before. As such it’s imperative that every software developer has experience installing and configuring such tools from scratch thus ensuring that they have the knowledge needed to troubleshoot when things go wrong.


Submit a Comment

Your email address will not be published. Required fields are marked *

10 − 4 =

Related Articles