Learn how to install Jenkins on Linux 9 with our detailed step-by-step guide. Streamline your continuous integration and continuous delivery (CI/CD) pipelines by setting up this powerful automation server on your Linux environment. #centlinux #linux #jenkins
Table of Contents
What is CI/CD?
In DevOps practices, the 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.
What is Jenkins?
Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat. It supports version control tools, including AccuRev, CVS, Subversion, Git, Mercurial, Perforce, ClearCase and RTC, and can execute Apache Ant, Apache Maven and sbt based projects as well as arbitrary shell scripts and Windows batch commands. (Source: Wikipedia)
Plugins have been released for Jenkins that extend its use to projects written in languages other than Java. Plugins are available for integrating Jenkins with most version control systems and bug databases. Many build tools are supported via their respective plugins. Plugins can also change the way Jenkins looks or add new functionality. There are a set of plugins dedicated for the purpose of unit testing that generate test reports in various formats (for example, JUnit bundled with Jenkins, MSTest, NUnit, etc.) and automated testing that supports automated tests. Builds can generate test reports in various formats supported by plugins (JUnit support is currently bundled) and Jenkins can display the reports and generate trends and render them in the GUI.
Read Also:
Environment Specification
For this tutorial, we are working with a minimal installation of Rocky Linux 9, deployed on a virtual machine configured to provide optimal performance for our tasks. This setup ensures a clean and lightweight environment, free from unnecessary services and packages, making it an ideal base for server setups, testing, or development purposes. Below are the specifications of our virtual machine, which you can use as a reference to replicate this setup for your own use cases.
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – Rocky Linux release 9.0 (Blue Onyx)
- Hostname – jenkins-01.centlinux.com
- IP Address – 192.168.116.131/24
Recommended Training: Jenkins: Jobs, Pipelines, CI/CD and DevOps for Beginners from Valentin Despa
Update Linux Operating System
Connect with your Rocky Linux 9 server as root user by means of a ssh client.
Set a meaningful FQDN (Fully Qualified Domain Name) for your Linux machine by executing hostnamectl command.
# hostnamectl set-hostname jenkins-01.centlinux.com
Rebuild cache of your yum package manager.
# dnf makecache --refresh Rocky Linux 9 - BaseOS 105 kB/s | 1.7 MB 00:16 Rocky Linux 9 - AppStream 354 kB/s | 6.0 MB 00:17 Rocky Linux 9 - Extras 873 B/s | 2.9 kB 00:03 Metadata cache created.
Execute following command to update your Rocky Linux operating system.
# dnf upgrade -y
Sometimes, the above command also updates Linux Kernel. In this case, you should reboot your Linux operating system before moving forward.
# reboot
After reboot, verify the Operating system and Kernel versions.
# cat /etc/rocky-release Rocky Linux release 9.0 (Blue Onyx) # uname -r 5.14.0-70.26.1.el9_0.x86_64
TP-Link AX3000 WiFi 6 Router – 802.11ax Wireless Router, Gigabit, Dual Band Internet Router, VPN Router, OneMesh Compatible (Archer AX55)
$79.99 (as of January 20, 2025 18:30 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Install OpenJDK on Rocky Linux 9
Jenkins is a Java application, thus it requires Java Virtual Machine (JVM) for execution.
Jenkins 2.3 is current stable version and it requires Java 11.
Luckily, OpenJDK Java 11 is available in standard yum repositories. Therefore, you can easily install it by using dnf command.
# dnf install -y java-11-openjdk-devel java-11-openjdk
After successful installation, verify the version of active Java on your Linux platform.
# java --version openjdk 11.0.17 2022-10-18 LTS OpenJDK Runtime Environment (Red_Hat-11.0.17.0.8-2.el9_0) (build 11.0.17+8-LTS) OpenJDK 64-Bit Server VM (Red_Hat-11.0.17.0.8-2.el9_0) (build 11.0.17+8-LTS, mixed mode, sharing)
Install Jenkins on Linux
Jenkins can be install in three ways.
- 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 prefer to use Jenkins yum repository, because, it is quite simple to understand and in this method software dependencies will be resolved automatically.
You will need wget command to download Jenkins official yum repository. Therefore, install it now.
# dnf install -y wget
By using wget command, download Jenkins yum repository into /etc/yum.repos.d directory.
# wget https://pkg.jenkins.io/redhat-stable/jenkins.repo -O /etc/yum.repos.d/jenkins.repo --2022-10-31 11:29:47-- https://pkg.jenkins.io/redhat-stable/jenkins.repo Resolving pkg.jenkins.io (pkg.jenkins.io)... 199.232.46.133, 2a04:4e42:48::645 Connecting to pkg.jenkins.io (pkg.jenkins.io)|199.232.46.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 85 Saving to: ‘/etc/yum.repos.d/jenkins.repo’ /etc/yum.repos.d/je 100%[===================>] 85 --.-KB/s in 0s 2022-10-31 11:29:49 (3.94 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]
Import the GPG Key of Jenkins yum repository.
# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Build the yum cache for recently added repositories.
# dnf makecache Jenkins-stable 5.7 kB/s | 24 kB 00:04 Rocky Linux 9 - BaseOS 1.1 kB/s | 3.6 kB 00:03 Rocky Linux 9 - AppStream 2.0 kB/s | 3.6 kB 00:01 Rocky Linux 9 - Extras 1.4 kB/s | 2.9 kB 00:02 Metadata cache created.
Now, you can easily install Jenkins by invoking dnf command.
# dnf install -y jenkins Last metadata expiration check: 0:00:28 ago on Mon 31 Oct 2022 11:30:49 AM CDT. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: jenkins noarch 2.361.2-1.1 jenkins 89 M Transaction Summary ================================================================================ Install 1 Package Total download size: 89 M Installed size: 89 M Downloading Packages: jenkins-jenkins-2.361.2-1.1. 0% [ ] --- B/s | 0 B --jenkins-2.361.2-1.1.noarch.rpm 616 kB/s | 89 MB 02:27 -------------------------------------------------------------------------------- Total 616 kB/s | 89 MB 02:27 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: jenkins-2.361.2-1.1.noarch 1/1 Installing : jenkins-2.361.2-1.1.noarch 1/1 Running scriptlet: jenkins-2.361.2-1.1.noarch 1/1 Verifying : jenkins-2.361.2-1.1.noarch 1/1 Installed: jenkins-2.361.2-1.1.noarch Complete!
Razer Basilisk V3 Pro 35K Wireless Gaming Mouse: HyperScroll Tilt Wheel – 35K DPI Optical Sensor Gen 2-13 Customizable Controls – Chroma RGB – Optical Switches Gen 3 – Up to 140 Hr Battery – Black
$149.89 (as of January 20, 2025 18:30 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configure Systemd Service:
Enable and start the Jenkins service.
# systemctl enable --now jenkins.service Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service.
Verify the status of Jenkins service.
# systemctl status jenkins.service
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor p>
Active: active (running) since Mon 2022-10-31 11:36:53 CDT; 8s ago
Main PID: 2260 (java)
Tasks: 43 (limit: 5736)
Memory: 338.7M
CPU: 1min 48.907s
CGroup: /system.slice/jenkins.service
└─2260 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java>
Oct 31 11:36:53 jenkins-01.centlinux.com systemd[1]: Started Jenkins Continuous>
Oct 31 11:36:55 jenkins-01.centlinux.com jenkins[2260]: 2022-10-31 16:36:55.032>
Configure Linux Firewall
Jenkins default service port is 8080/tcp. Therefore, you need to allow this port in Linux Firewall to make you Jenkins server accessible from the network.
Use firewall-cmd command to allow Jenkins service port in Linux firewall.
# firewall-cmd --permanent --add-port=8080/tcp success # firewall-cmd --reload success
Ultimate Robotics Programming with ROS 2 and Python: Design, Develop, and Implement Intelligent Robotics Applications with Advanced Navigation, Simulation, … and Industrial Robots (English Edition)
$18.99 (as of January 19, 2025 18:28 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Access Jenkins Web Interface
To access Jenkins web interface, open URL http://jenkins-01.centlinux.com:8080 in a web browser.
You can obtain the auto-generated password from the file, that was mentioned in above image.
# cat /var/lib/jenkins/secrets/initialAdminPassword
Enter the auto-generated password and click on “Continue”.
Jenkins setup is now asking for installing Plugins. You can either choose your required plugins or install suggested plugins.
Click on “Install suggested plugins”.
Jenkins setup is now installing commonly used plugins for your CI/CD software.
After installing plugins, Jenkins setup is now giving you the option to create an Admin user.
However, you can skip user creation and use the default admin user. But we strongly recommend that, you should create a custom admin user to improve security for your Jenkins web interface.
Verify the auto-generated Jenkins URL and click on “Save and Finish”.
Jenkins setup has been completed. Click on “Start using Jenkins”.
You have reached at the Dashboard of your Jenkins web interface.
Video Tutorial
To further assist you with the installation process, we recommend watching our step-by-step video tutorial on “How to Install Jenkins on Linux 9.” The video visually guides you through every stage of the installation, from setting up the required repositories to configuring Jenkins and accessing its web interface. It provides clear explanations and demonstrations, making it easier to follow along, even if you’re new to Jenkins or Linux administration. Watching the tutorial ensures you don’t miss any critical steps and helps clarify complex configurations. Be sure to check it out for a comprehensive understanding!
Final Thoughts
Congratulations on successfully installing Jenkins on Rocky Linux 9! With Jenkins set up, you’re now equipped to streamline your continuous integration and continuous delivery (CI/CD) pipelines. This powerful automation server will enhance your development workflow, enabling you to build, test, and deploy applications more efficiently. Embrace the capabilities of Jenkins to boost your productivity and achieve smoother, more reliable software delivery. Happy automating!
Searching for a skilled Linux admin? From server management to security, I ensure seamless operations for your Linux systems. Find out more on my Fiverr profile!
[root@localhost jenkins]# update-alternatives –config java
There is 2 program that provides 'java'.
Selection Command
———————————————–
*+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el8_7.x86_64/jre/bin/java)
2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el8_7.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number: 2
[root@localhost jenkins]#
It looks like, you are not installing on a minimal Linux OS. No problem, if you have multiple Java installations you can always use update-alternatives or alternatives command to select your preferred version.