Introduction
Looking to streamline your software development and deployment processes? Jenkins, an open-source automation server, can be your go-to tool. In this step-by-step guide, we’ll walk you through the process of installing Jenkins on CentOS 8, enabling you to automate your build, test, and deployment tasks efficiently. Let’s dive in!
Prerequisites
Jenkins is free and the most popular open-source for automation server. It is used to automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery (CI/CD) pipeline. 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.
Before you begin the installation process, ensure that you have the following prerequisites in place:
- CentOS 8 server with administrative access
- Java Development Kit (JDK) installed (version 8 or higher)
- A stable internet connection
1. Installing Java Development Kit (JDK)
To run Jenkins, you’ll need to install the Java Development Kit. Follow these steps to install JDK on CentOS 8:
Step 1: Update System Packages
sudo dnf update
Step 2: Install OpenJDK
sudo dnf install java-1.8.0-openjdk-devel
Step 3: Verify the Java Installation
java -version
Output :
[ramans@otodiginet ~]$ java -version openjdk version "11.0.8" 2020-07-14 LTS OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
2. Jenkins Installation
Now that we have Java installed, let’s proceed with installing Jenkins:
Step 1: Import Jenkins Repository Key
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Step 2: Add Jenkins Repository
$ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
Output :
[ramans@otodiginet ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo [sudo] password for ramans: --2020-12-22 18:58:03-- https://pkg.jenkins.io/redhat-stable/jenkins.repo Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.10.133, 2a04:4e42:2::645 Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.10.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 85 Saving to: ‘/etc/yum.repos.d/jenkins.repo’ /etc/yum.repos.d/jenkins. 100%[===================================>] 85 --.-KB/s in 0s 2020-12-22 18:58:04 (1.56 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]
Step 3: Install Jenkins
$ sudo dnf install jenkins
Output :
[ramans@otodiginet ~]$ sudo dnf install jenkins Jenkins-stable 18 kB/s | 19 kB 00:01 Last metadata expiration check: 0:00:01 ago on Tue 22 Dec 2020 06:59:11 PM PST. Dependencies resolved. ====================================================================================================== Package Architecture Version Repository Size ====================================================================================================== Installing: jenkins noarch 2.263.1-1.1 jenkins 64 M Transaction Summary ====================================================================================================== Install 1 Package Total download size: 64 M Installed size: 64 M Is this ok [y/N]: y Downloading Packages: jenkins-2.263.1-1.1.noarch.rpm 87 kB/s | 64 MB 12:30 ------------------------------------------------------------------------------------------------------ Total 87 kB/s | 64 MB 12:30 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: jenkins-2.263.1-1.1.noarch 1/1 Installing : jenkins-2.263.1-1.1.noarch 1/1 Running scriptlet: jenkins-2.263.1-1.1.noarch 1/1 Verifying : jenkins-2.263.1-1.1.noarch 1/1 Installed products updated. Installed: jenkins-2.263.1-1.1.noarch Complete!
Step 4: Start Jenkins Service
$ sudo systemctl start jenkins
Step 5: Enable Jenkins Service to Start on Boot
$ sudo systemctl enable jenkins
Output :
[ramans@otodiginet ~]$ sudo systemctl enable jenkins jenkins.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable jenkins
Step 6: Checking Jenkins Service Status
$ sudo systemctl status jenkins
Output :
[ramans@otodiginet ~]$ sudo systemctl status jenkins ● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; generated) Active: active (running) since Tue 2020-12-22 19:20:14 PST; 15s ago Docs: man:systemd-sysv-generator(8) Tasks: 32 (limit: 49614) Memory: 246.8M CGroup: /system.slice/jenkins.service └─6996 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -> Dec 22 19:20:12 otodiginet systemd[1]: Starting LSB: Jenkins Automation Server... Dec 22 19:20:13 otodiginet runuser[6975]: pam_unix(runuser:session): session opened for user jenkins > Dec 22 19:20:14 otodiginet runuser[6975]: pam_unix(runuser:session): session closed for user jenkins Dec 22 19:20:14 otodiginet jenkins[6968]: Starting Jenkins [ OK ] Dec 22 19:20:14 otodiginet systemd[1]: Started LSB: Jenkins Automation Server.
3. Configuring Jenkins
Now that Jenkins is installed on our CentOS 8 system, let’s configure it:
Step 1: Access Jenkins Web Interface
Open your web browser and enter http://<your-server-IP>:8080
in the address bar.
Step 2: Unlock Jenkins
Retrieve the initial administrator password by executing the following command:
$ sudo more /var/lib/jenkins/secrets/initialAdminPassword
Output :
[ramans@otodiginet ~]$ sudo more /var/lib/jenkins/secrets/initialAdminPassword [sudo] password for ramans: d4ee060068484324ad56b73c0795ed66
Copy the password and paste it into the Jenkins web interface.
Step 3: Install Recommended Plugins
Choose the “Install suggested plugins” option to install the recommended plugins.
Step 4: Create an Admin User
Provide the required information to create an admin user for Jenkins.
Step 5: Configure Jenkins URL
Specify the URL for Jenkins to use. Use the default URL if you’re accessing Jenkins directly via IP.
5: Jenkins Installation Completion
Congratulations! We have successfully installed Jenkins on CentOS 8. Here are a few final steps to wrap up the installation:
Step 1: Start Using Jenkins
Click on the “Start using Jenkins” button to access the Jenkins dashboard.
Step 2: Install Additional Plugins (optional)
Explore the Jenkins dashboard to install additional plugins according to your project requirements.
Conclusion
By following this step-by-step guide, you have learned how to install Jenkins on CentOS 8 and configure it for your software development needs. Jenkins provides a powerful platform for automating build, test, and deployment processes, enabling you to streamline your workflows and enhance efficiency. Get started with Jenkins today and revolutionize your software development practices!
Remember to regularly update and secure your Jenkins installation to ensure optimal performance and stability. Happy automating!