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
Table of Contents
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.
Obtain the autogenerated password from the given file.
# cat /var/lib/jenkins/secrets/initialAdminPassword 1f6a106d9af642909ad0ecc5abd8afec
Unlock Jenkins using this password.
Click on continue.
Click on Install Suggested Services.
Jenkins will install most commonly used plugins such as Apache Ant, Gradle, Git, etc.
Create an Admin user here.
Click on Save and Continue.
Jenkins provide a root URL here for accessing its various resources.
If you are happy with it then click on Save and Finish.
Jenkins has been successfully configured.
Click on Start using Jenkins.
Login using the admin user ahmer that we have created with Jenkins Setup Wizard.
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.