Jenkins

How to install Jenkins on CentOS 7

Share on Social Media

Learn how to install Jenkins on CentOS 7 with our detailed guide. Follow step-by-step instructions to set up this powerful automation server on your system. #centlinux #linux #devops

What is Jenkins?

Jenkins is a Java-based, open-source automation server. Jenkins is used to automate all sorts of tasks related to building, testing and delivering or deploying software. Jenkins is a fork of Project Hudson and it is maintained by the original Hudson developers since the Hudson had been acquired by Oracle. However, Jenkins has been evolved very much since its inception from Hudson.

What is CI/CD Pipeline?

In DevOps, this automated process of building, testing and delivering is called CI/CD (Continuous Integration / Continuous Delivery) pipeline.

CI (Continuous integration) is a practice in which team members regularly commits their code changes to the version control repository (such as git or svn), after which automated builds and tests are performed using build tools (such as Apache Ant, Apache Maven, Gradle, Junit, etc).

CD (Continuous delivery) is a series of practices where code changes are automatically built, tested and deployed to production.

In this article, we will install Jenkins on CentOS 7 server. Although the same steps can be used to install Jenkins on Red Hat Enterprise Linux (RHEL) 7.

Read Also: How to install Jenkins on Rocky Linux 9

System Specification

We have provisioned a CentOS 7 virtual machine with following specification:

  • Hostname – jenkins-01.recipes.com
  • IP Address – 192.168.116.130/24
  • Operating System – CentOS 7.6

Recommended Online Training: Learn Bash Shell in Linux for Beginners

Install OpenJDK on CentOS 7

Since, Jenkins is a Java application therefore it requires JVM (Java Virtual Machine) to execute. Jenkins 2 is the current major version and it requires Java 8.

Connect to jenkins-01.recipes.com using ssh and install OpenJDK from CentOS 7 yum repository.

# yum install -y java-1.8.0-openjdk-devel

yum has installed OpenJDK and its dependent packages.

Java executables has been automatically added to PATH environment variable. Therefore, we are only required to set the JAVA_HOME environment variable.

# echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64" >> /etc/profile
# . /etc/profile
# env | grep JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64

Verify Java version.

# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

OpenJDK has been installed and configured successfully.

Install Jenkins on CentOS 7

Jenkins is available to install in various forms.

  • Individual RPM:
    Individual RPMs are available for every version of Jenkins, but one has to resolve dependencies manually.
  • Jenkins yum Repository:
    A Yum repository is provided for Jenkins packages. Here, dependent packages will be installed automatically.
  • Generic Web Archive:
    This Java web archive requires to be executed either using java command or should be deployed on a Jave EE Server (e.g Apache Tomcat) to work.

We will use Jenkins yum repository, because, it is quite simple to understand and in this method dependencies will resolved automatically.

Jenkins can be downloaded from Jenkins download page. Jenkins website also provides commands to install Jenkins yum repository on CentOS 7.

Install jenkins yum repository using the following commands.

# wget https://pkg.jenkins.io/redhat-stable/jenkins.repo -O /etc/yum.repos.d/jenkins.repo
--2019-01-08 00:14:26--  https://pkg.jenkins.io/redhat-stable/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 52.202.51.185
Connecting to pkg.jenkins.io (pkg.jenkins.io)|52.202.51.185|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85
Saving to: â/etc/yum.repos.d/jenkins.repoâ

100%[======================================>] 85          --.-K/s   in 0s

2019-01-08 00:14:27 (5.48 MB/s) - â/etc/yum.repos.d/jenkins.repoâ saved [85/85]

# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

Build yum cache for faster access to repositories.

# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ges.net.pk
 * extras: mirrors.ges.net.pk
 * updates: mirrors.ges.net.pk
base                                                     | 3.6 kB     00:00
extras                                                   | 3.4 kB     00:00
jenkins                                                  | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
Metadata Cache Created

Install Jenkins on CentOS 7 using yum command.

# yum install -y jenkins

Start and enable jenkins service.

# systemctl start jenkins
# systemctl enable jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on

Configure Linux Firewall

Allow Service Port 8080/tcp in Linux Firewall.

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

Configure Jenkins Server

Browse URL http://jenkins-01.recipes.com:8080/jenkins using a client browser.

Unlock Jenkins 1

Obtain the autogenerated password from the given file.

# cat /var/lib/jenkins/secrets/initialAdminPassword
1f6a106d9af642909ad0ecc5abd8afec

Unlock Jenkins using this password.

Unlock Jenkins 2

Click on continue.

Customize Jenkins

Click on Install Suggested Services.

Jenkins Server – Getting Started

Jenkins will install most commonly used plugins such as Apache Ant, Gradle, Git, etc.

Jenkins – Create First Admin User

Create an Admin user here.

Click on Save and Continue.

Jenkins Instance Configuration

Jenkins provide a root URL here for accessing its various resources.

If you are happy with it then click on Save and Finish.

Jenkins is Ready

Jenkins has been successfully configured.

Click on Start using Jenkins.

Jenkins is Loading
Jenkins Login

Login using the admin user ahmer that we have created with Jenkins Setup Wizard.

Jenkins Dashboard

Installation of Jenkins 2 on CentOS 7 has been completed.

You can refer to Jenkins User Documentation to understand the workflow and getting start with Jenkins.

Final Thoughts

Installing Jenkins on CentOS 7 can significantly enhance your automation capabilities, streamlining your development and deployment processes. By following this guide, you should now have a fully functional Jenkins setup. If you encounter any challenges or require further customization, professional assistance is highly recommended.

For expert setup and configuration services, visit my Fiverr profile where I offer specialized services for installing Jenkins on CentOS 7. Let me help you optimize your CI/CD pipeline with a perfectly configured Jenkins instance.

Alaric Bird

Alaric Bird is a seasoned Linux System Administrator with over a decade of experience in managing and optimizing Linux-based servers and infrastructure. Known for his expertise in server deployment, security hardening, and performance tuning, Alaric has a deep understanding of various Linux distributions, including Ubuntu, CentOS, and Red Hat Enterprise Linux. His skills extend to cloud platforms like AWS, where he effectively manages virtual private servers and services. Alaric is also proficient in scripting languages such as Bash and Python, which he uses to automate routine tasks, enhancing efficiency and reliability. With a strong commitment to continuous learning, he stays updated with the latest developments in open-source technologies and best practices. His problem-solving abilities, combined with excellent communication skills, make him a valuable asset to any IT team. In addition to his technical expertise, Alaric is passionate about mentoring junior administrators and fostering a collaborative environment.

Share
Published by
Alaric Bird

Recent Posts

Change Apache Document Root in Linux

Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…

2 weeks ago

How to Change Apache Port in Linux

Discover how to change Apache port in Linux easily. Follow our simple guide to modify…

2 weeks ago

How to Create Virtual Host in Apache Server

Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…

3 weeks ago

10 Practical Tasks for RHCSA Exam with Solutions

Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…

3 weeks ago

Ultimate Fail2ban Configuration Guide

Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…

3 weeks ago

VPS Server: The Ultimate Guide to Virtual Private Servers

Explore the ultimate guide to VPS servers and learn everything about Virtual Private Servers, including…

4 weeks ago

This website uses cookies.