Build with Java language, Jenkins is an open-source automation platform that provide support for Continuous Integration and Continuous Delivery (CI/CD) for development of any software. The first version of Jenkins was releaed under MIT License in February 2 2011 by its original author “Kohsuke Kawaguchi”. There are hundreds of plugin available to support Jenkins in deployment, build and automate the applications in DevOps ecosystem. Currently Jenkins is available in version 2.337 as the latest stable release which published in March 1, 2022.
Jenkins give the developer easy installation instruction for different environment, either on operating system (Windows, Linux or Mac), or container-based system. Since its self-contained Java-based program, Jenkins can work in different operating system and can be installed via web-based intercafe. You can integrate the plugins with Jenkins which is available in Update Center to support CI/CD development.
To help the developer in build, deploy, and test the application or software in various environment, user can integrated Jenkins with its plugin. You can run Jenkins as a standalone application which working on its own process, where its built-in Java servlet container or application server (Jetty). Another environment where Jenkins can work it’s on a server-based system (servlet) in various Java servlet containers, including GlassFish and Apache Tomcat. There are different version control system where Jenkins support on it, including Git, Mercurial, Subversion, Apache Maven, AccuRev, and CVS.
Apart from that, Jenkins can also work as an simple CI-based server or turn it to the CD hub to support all of developer need project. So, in order to install Jenkins on your machine, make sure to fill the following requirenments.
PREREQUISITES:
* VPS, Cloud, or Bare-Metal Server * Distro Flavours Rocky Linux 8.5 (Green Obsidian) * Server IPv4 Address with SUDO Access * Gnome Terminal for Linux Desktop * PuTTy SSH Client for Windows or Mac * Powershell for Windows 10/11 * Minimum hardware requirements: ** Memory: 256 MB ** Storage Space: 1GB (10GB for Jenkins with a Docker container) * Recommended hardware configuration for a small team: ** Memory: 4 GB+ ** Storage Space: 50 GB+
1.) Add Red Hat / CentOS Repository
We will use Red Hat / CentOS Repository to install Jenkins into our virtual machine. As its available on the official documentations, Jenkins could be installed using RedHat or CentOS stable repository. You can install Jenkins on various Linux-based operating system, including Debian and its derivative like Ubuntu, and also Fedora/RedHat based OS like CentOS, Rocky Linux and AlmaLinux.
We will use my development server to deploy Jenkins inside my virtual machine. Login with SUDO access into the server using the following command. Make sure to replace server IPv4 address and port with your actual server IPv4 address and port.
$ ssh [email protected] -p4322 [email protected]'s password: Web console: https://open-source.project:9090/ or https://45.55.41.24:9090/ Last login: Mon May 2 22:16:07 2022 from 180.248.10.163 [root@open-source ~]#
Then, let’s adding the Jenkins repository to your machine using the following commands.
$ wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.repo --2022-05-06 06:37:24-- https://pkg.jenkins.io/redhat-stable/jenkins.repo Resolving pkg.jenkins.io (pkg.jenkins.io)... 2a04:4e42:46::645, 199.232.38.133 Connecting to pkg.jenkins.io (pkg.jenkins.io)|2a04:4e42:46::645|: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-05-06 06:37:25 (2.21 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]
$ rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
$ yum upgrade DigitalOcean Agent 77 kB/s | 3.3 kB 00:00 DigitalOcean Droplet Agent 56 kB/s | 3.3 kB 00:00 Jenkins-stable 1.3 kB/s | 23 kB 00:17 Dependencies resolved. ===================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================== Upgrading: epel-release noarch 8-15.el8 epel 23 k k6 x86_64 0.38.0-1 k6 8.9 M oniguruma5php x86_64 6.9.8-1.el8.remi remi-safe 212 k Transaction Summary ===================================================================================================================================================== Upgrade 3 Packages Total download size: 9.2 M Is this ok [y/N]: y
# Add required dependencies for the jenkins package
$ systemctl daemon-reload
2.) Install Java as Dependency
Jenkins need Java as a software dependency to work on its environment and currently only Java version 8 and 11 are support Jenkins. Siply run the following command to install Java language on your virtual machine.
$ yum install java-11-openjdk Last metadata expiration check: 0:03:56 ago on Fri 06 May 2022 06:39:09 AM UTC. Dependencies resolved. ===================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================== Installing: java-11-openjdk x86_64 1:11.0.15.0.9-2.el8_5 appstream 267 k Installing dependencies: adwaita-cursor-theme noarch 3.28.0-2.el8 appstream 646 k adwaita-icon-theme noarch 3.28.0-2.el8 appstream 11 M alsa-lib x86_64 1.2.5-4.el8 appstream 488 k at-spi2-atk x86_64 2.26.2-1.el8 appstream 88 k at-spi2-core x86_64 2.28.0-1.el8 appstream 168 k atk x86_64 2.28.1-1.el8 appstream 270 k colord-libs x86_64 1.4.2-1.el8 appstream 234 k copy-jdk-configs noarch 4.0-2.el8 appstream 29 k cups-libs x86_64 1:2.2.6-40.el8 baseos 432 k gdk-pixbuf2-modules x86_64 2.36.12-5.el8 appstream 108 k giflib x86_64 5.1.4-3.el8 appstream 50 k gtk-update-icon-cache x86_64 3.22.30-8.el8 appstream 31 k hicolor-icon-theme noarch 0.17-2.el8 appstream 47 k jasper-libs x86_64 2.0.14-5.el8 appstream 166 k java-11-openjdk-headless x86_64 1:11.0.15.0.9-2.el8_5 appstream 40 M javapackages-filesystem noarch 5.3.0-2.module+el8.3.0+125+5da1ae29 appstream 29 k lcms2 x86_64 2.9-2.el8 appstream 163 k libXcomposite x86_64 0.4.4-14.el8 appstream 27 k libXcursor x86_64 1.1.15-3.el8 appstream 35 k libXdamage x86_64 1.1.4-14.el8 appstream 26 k libXfixes x86_64 5.0.3-7.el8 appstream 24 k libXft x86_64 2.3.3-1.el8 appstream 66 k libXi x86_64 1.7.10-1.el8 appstream 48 k libXinerama x86_64 1.1.4-1.el8 appstream 14 k libXrandr x86_64 1.5.2-1.el8 appstream 33 k libXtst x86_64 1.2.3-7.el8 appstream 21 k libdatrie x86_64 0.2.9-7.el8 appstream 32 k libepoxy x86_64 1.5.8-1.el8 appstream 224 k libfontenc x86_64 1.1.3-8.el8 appstream 36 k libgusb x86_64 0.3.0-1.el8 baseos 48 k libthai x86_64 0.1.27-2.el8 appstream 202 k libwayland-client x86_64 1.19.0-1.el8 appstream 38 k libwayland-cursor x86_64 1.19.0-1.el8 appstream 25 k libwayland-egl x86_64 1.19.0-1.el8 appstream 18 k lksctp-tools x86_64 1.0.18-3.el8 baseos 98 k lua x86_64 5.3.4-12.el8 appstream 191 k pango x86_64 1.42.4-8.el8 appstream 296 k rest x86_64 0.8.1-2.el8 appstream 69 k ttmkfdir x86_64 3.0.9-54.el8 appstream 61 k tzdata-java noarch 2022a-1.el8 appstream 190 k xorg-x11-font-utils x86_64 1:7.5-41.el8 appstream 103 k xorg-x11-fonts-Type1 noarch 7.5-19.el8 appstream 521 k Installing weak dependencies: dconf x86_64 0.28.0-4.el8 appstream 107 k gtk3 x86_64 3.22.30-8.el8 appstream 4.5 M Enabling module streams: javapackages-runtime 201801 Transaction Summary ===================================================================================================================================================== Install 45 Packages Total download size: 61 M Installed size: 227 M Is this ok [y/N]: y
Verify Java version using the following command.
$ java --version openjdk 11.0.15 2022-04-19 LTS OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)
3.) Let’s Install Jenkins LTS
After that simply run the following command to install Jenkins on your virtual machine. We can choose a stable version of Jenkins LTS release (Long-Term Support), instead of Weekly Release or non-stable version. Simply run the following command to install Jenkins.
$ yum install jenkins DigitalOcean Agent 94 kB/s | 3.3 kB 00:00 DigitalOcean Droplet Agent 68 kB/s | 3.3 kB 00:00 Dependencies resolved. ===================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================== Installing: jenkins noarch 2.332.3-1.1 jenkins 90 M Transaction Summary ===================================================================================================================================================== Install 1 Package Total download size: 90 M Installed size: 91 M Is this ok [y/N]: y
Then you can verify the Jenkins version installed in your machine.
$ jenkins --version 2.332.3
As you can see above that the version installed of Jenkins is version 2.332.3.
4.) Manage Jenkins on Your Machine
First of all, you need to reload the Daemon on your node using the following command.
$ systemctl daemon-reload
Then to manage a Jenkins server you can use the following command to Start, Stop, Restart and Check Status of Jenkins service.
Make sure to enable Jenkins to start from VM boot.
$ systemctl enable jenkins Synchronizing state of jenkins.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable jenkins Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service.
To Start Jenkins
$ systemctl start jenkins
To Stop Jenkins
$ systemctl stop jenkins
To Restart Jenkins
$ systemctl restart jenkins
To Check Jenkins Status
$ systemctl status jenkins ● jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-05-06 07:07:11 UTC; 18s ago Main PID: 400337 (java) Tasks: 43 (limit: 4730) Memory: 207.6M CGroup: /system.slice/jenkins.service └─400337 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 May 06 07:06:40 open-source.project jenkins[400337]: 2022-05-06 07:06:40.899+0000 [id=29] INFO jenkins.install.SetupWizard#init: May 06 07:06:40 open-source.project jenkins[400337]: ************************************************************* May 06 07:06:40 open-source.project jenkins[400337]: Jenkins initial setup is required. An admin user has been created and a password generated. May 06 07:06:40 open-source.project jenkins[400337]: Please use the following password to proceed to installation: May 06 07:06:40 open-source.project jenkins[400337]: a277e60856294e3c8fb2b2ce84e3b796 May 06 07:06:40 open-source.project jenkins[400337]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword May 06 07:06:40 open-source.project jenkins[400337]: ************************************************************* May 06 07:07:11 open-source.project jenkins[400337]: 2022-05-06 07:07:11.319+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained:> May 06 07:07:11 open-source.project jenkins[400337]: 2022-05-06 07:07:11.371+0000 [id=22] INFO hudson.lifecycle.Lifecycle#onReady: Jen> May 06 07:07:11 open-source.project systemd[1]: Started Jenkins Continuous Integration Server.
5.) Configure Jenkins via Web Browser
After that we can configure Jenkins via web browser, either it Google Chrome or Mozilla Firefox. If you have active Firewall running in your machine, make sure to add port 8080 to your Firewall rules. It’s actually HTTP or plain port which serve Jenkins to run via its web-based iterface.
Since node machine use ConfigServer Security & Firewall (CSF) and Login Failure Daemon (LFD), so we need to add the TCP port 8080 to my CSF configuration rules as below.
$ nano /etc/csf/csf.conf --------------------------------------------------------------- # This option should be set to "1" in all other circumstances LF_SPI = "1" # Allow incoming TCP ports TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,4322,8080" # Allow outgoing TCP ports TCP_OUT = "20,21,22,25,53,80,110,113,443,587,993,995,8080" ---------------------------------------------------------------
Then restart the Firewall using the following command.
$ csf -r $ lfd -r
To configure Jenkins via web browsers:
* Jenkins URL: http://server_IPv4_address:8080/
On this case:
* Jenkins URL: http://45.55.41.24:8080/
6.) Setting up Jenkins
You need to know the initial Admin Password to Unlock Jenkins and finishing the configurations. It’s actually administrator password which keep it into the initialAdminPassword secret file. Use this command to copy the Jenkins admin password.
$ tail -f /var/lib/jenkins/secrets/initialAdminPassword a277e60856294e3c8fb2b2ce84e3b796 In this case my Jenkins admin password is a277e60856294e3c8fb2b2ce84e3b796, so to continue the configuring Jenkins you need to replace it with your actual Jenkins administrative password as its written on your initialAdminPassword log file.
7.) Install Recommended Plugins, Create Admin User and Finish Configuring Jenkins
There are available recomended plugins which you can install during configuring Jenkins in web browsers. So, you can install it to extend Jenkins with available extra features to support many different software developments. Next, you can create first administrative user on your Jenkins server before you can finish configuring your Jenkins instance.
CONCLUSION:
You have successfully install and configure Jenkins Server on Rocky Linux 8.5 (Green Obsidian) to support your software development or project for automate applications.