Skip to main content

Installing and configuring Jenkins in Linux

Jenkins provides CI/CD functionality, making sysadmin and developer lives easier. See how to install and set up this useful service.
Image
How to install Jenkins on Red Hat Enterprise Linux 8

Photo by Tiger Lily from Pexels

Jenkins is an open source automation server based on Java. It works on the top of servlet containers. Jenkins is used to setup CI/CD pipelines for projects and makes them DevOps-oriented. Jenkins makes it easy for developers to integrate their changes by continuously testing, building, and deploying the projects easily with minimal setup required.

Jenkins builds the software in an agile and continuous manner and helps to achieve failFast as it discards the pipeline as soon as an error or bug is discovered and notifies the developer at an early stage.

[ You might also enjoy: What's your favorite automation tool? ]

Jenkins has a strong community with a large number of developers who are continuously working on designing plugins to achieve more from Jenkins. Such work allows the integration of various DevOps tools. Jenkins currently has 1700+ plugins available.

Why Jenkins?

  1. Open source tool with an involved community - Jenkins is an open source tool and available free to use. Its documentation is extensive and is extensible. The Jenkins community is also available for any kind of help.
  2. Easy installation - Being developed in Java, it is a platform-independent app and available for almost all operating systems. Even after installation, the Jenkins Console is easily accessible over a WebUI.
  3. Enormous plugin ecosystem - Jenkins has over 1700+ plugins available to extend its functionality, and more are being developed continuously. Even if you want to work with something and a plugin is not available, you can code it and share it with the community.
  4. Automation - Jenkins reduces the chance of errors as the complete work is automated without manual intervention. Errors caused by manual methods are decreased, and monitoring is done 24*7, which is impossible with manual intervention.

Prerequisites for installing Jenkins

Java needs to be installed and configured on the server on which you want to configure Jenkins. OpenJDK is preferred with Jenkins, but you can also use any other version of Java.

# yum install java-11-openjdk-devel

If multiple Java versions are installed on your server, you can specify the default Java version using this command:

# update-alternatives --config java

Install the wget tool in your operating system to fetch the Jenkins repository:

# yum install wget

Installing Jenkins

To install Jenkins on to your operating system, you first need to configure yum by adding the Jenkins repository and then import the repository GPG key:

# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

You can check the presence of the repo using this command:

# yum repolist

The following links are for the LTS version for Jenkins. You can also use the latest build.

When the repository is updated, you need to install Jenkins and start the service. Using the systemctl start command starts the Jenkins service and enabling the service will start it on bootup.

To check if the Jenkins service is running, use the command:

# systemctl status jenkins

You also need to add Jenkins service to run with firewall and add its exception so that it is available to access from the outside world. Finally, we need to reload the firewall service for the changes to take effect.

# firewall-cmd --add-port=8080/tcp --permanent
# firewall-cmd --reload

To check the firewall status and accessible ports, use the firewall-cmd command:

# firewall-cmd --list-all

Now, the Jenkins server will be running on port 8080 for our server.

Configuring Jenkins

You can configure the Jenkins service on port 8080 of your system, but Jenkins is temporarily locked with a password present in the  /var/lib/jenkins/secrets/initialAdminPassword file. You can access Jenkins by providing the password after reading the file.

Image
Unlock Jenkins

Remember to open the file with root user permissions as it is not accessible otherwise.

Install the suggested plugins for Jenkins. They are compatible with most versions, but if you want to do something specific, you can also select and work with the plugins you wish.

Image
Install Plugins

The plugins will take some time to install depending on the connectivity speed, so be patient.

Create an admin user. Make sure you remember the username and password, as they are the credentials for accessing the Jenkins WebUI.

Image
Admin Password

Specify if you wish to change the port for your Jenkins. It is preferred to use Jenkins on 8080 port.

Image
Jenkins Port

Jenkins setup is complete and it can be accessed with the URL that is configured for it.

Image
Jenkins Setup Complete

[ Looking for more on system automation? Get started with The Automated Enterprise, a free book from Red Hat. ] 

Wrapping up

In this article, you learned the basics of Jenkins and the steps for its configuration. This article covers working with the default plugins, but you can also use the different plugins for other functions. Lastly, Jenkins makes the sysadmin's job easier as it automatically triggers some of the tasks based on the defined events.

Check out these related articles on Enable Sysadmin

Topics:   Linux   Linux Administration   Automation  
Author’s photo

Kshitiz Saini

Kshitiz Saini is a pre-final year as a Computer Science undergraduate at the University of Petroleum and Energy Studies, Dehradun, and a tech enthusiast who seeks experience by learning to increase his knowledge along with having some fun. More about me

On Demand: Red Hat Summit 2021 Virtual Experience

Relive our April event with demos, keynotes, and technical sessions from
experts, and sign up to attend breakout sessions June 15–16.

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX