Atlantic.Net Blog

How to Install Jenkins on Rocky Linux 8

Hitesh Jethva
by Atlantic.Net (345 posts) under Dedicated Server Hosting, Tutorials
0 Comments

Jenkins is an open-source, widely used automation software tool. It is used in the software development life cycle to build, test, and deploy code automatically. Jenkins is written in Java and allows you to automate a series of tasks in order to complete the continuous integration process. It provides a simple and user-friendly web interface that allows you to manage complicated tasks through a web-based dashboard.

In this post, we will show you how to install Jenkins on Rocky Linux 8.

Prerequisites

  • A server running Rocky Linux 8 on the Atlantic.Net Cloud Platform
  • A root password is configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Rocky Linux as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Java

Jenkins is a Java-based tool, so Java must be installed on your server. If not installed, you can install it using the following command:

dnf install java-11-openjdk -y

Once Java is installed, verify the Java version using the following command:

java --version

Sample output:

openjdk 11.0.12 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

Step 3 – Add Jenkins Repository

By default, Jenkins is not included in the RockyLinux 8 default repository, so you will need to create a Jenkins repo to your system. You can create it using the following command:

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

Next, download and import the Jenkins GPG key with the following command:

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

Next, verify the Jenkins repo using the following command:

dnf repolist

Sample output:

repo id                                                         repo name
appstream                                                       Rocky Linux 8 - AppStream
baseos                                                          Rocky Linux 8 - BaseOS
extras                                                          Rocky Linux 8 - Extras
jenkins                                                         Jenkins-stable

Step 4 – Install Jenkins

Now, you can install Jenkins using the following command:

dnf install jenkins --nobest

Once Jenkins is installed, start Jenkins and enable it to start at system reboot:

systemctl start jenkins
systemctl enable jenkins

You can now check the status of Jenkins using the following command:

systemctl status jenkins

Sample output:

● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
   Active: active (running) since Wed 2021-09-22 07:11:09 UTC; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5106 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
    Tasks: 13 (limit: 11411)
   Memory: 129.1M
   CGroup: /system.slice/jenkins.service
           └─5129 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/>

Sep 22 07:11:07 RockyLinux8 systemd[1]: Starting LSB: Jenkins Automation Server...
Sep 22 07:11:08 RockyLinux8 runuser[5113]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Sep 22 07:11:09 RockyLinux8 runuser[5113]: pam_unix(runuser:session): session closed for user jenkins
Sep 22 07:11:09 RockyLinux8 jenkins[5106]: Starting Jenkins [  OK  ]
Sep 22 07:11:09 RockyLinux8 systemd[1]: Started LSB: Jenkins Automation Server.

By default, Jenkins listens on port 8080. You can verify it with the following command:

ss -antpl | grep 8080

Sample output:

LISTEN 0      50                 *:8080            *:*    users:(("java",pid=5129,fd=135))

Step 5 – Configure Nginx as a Reverse Proxy for Jenkins

It is recommended to install and configure Nginx as a reverse proxy for Jenkins. First, install the Nginx web server with the following command:

dnf install nginx -y

After installing Nginx, create an Nginx configuration file for Jenkins:

nano /etc/nginx/conf.d/jenkins.conf

Add the following lines:

upstream jenkins {
  server 127.0.0.1:8080 fail_timeout=0;
}

server {
  listen 80;
  server_name jenkins.example.com;

  location / {
    proxy_set_header        Host $host:$server_port;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_pass              http://jenkins;
    # Required for new HTTP-based CLI
    proxy_http_version 1.1;
    proxy_request_buffering off;
    proxy_buffering off; # Required for HTTP-based CLI to work over SSL
  }
}

Save and close the file when you are finished.

Next, verify Nginx for any syntax error:

nginx -t

Sample output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Please note if you get this warning message :

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed

You must edit the /etc/nginx.nginx.conf file and add this line before the server block:

server_names_hash_bucket_size 64;

Finally, start the Nginx service and enable it to start at system reboot:

systemctl start nginx
systemctl enable nginx

Step 6 – Access Jenkins Dashboard

Now, you can access the Jenkins web interface using the URL http://jenkins.example.com from the web browser. You should see the following screen:
Jenkins initial password
Now, open your terminal and retrieve the Jenkins setup password using the following command:

cat /var/lib/jenkins/secrets/initialAdminPassword

Sample output:

24934e3f8d7e453a92f99c3439f21f8a

Now, paste the above password and click on the Continue button. You should see the following screen:
Jenkins install plugins
Now, select ‘Install using suggested plugins‘ or ‘Select plugins to install‘. You should see the following screen:
Jenkins create admin user
Now, provide your admin user information and click on the Save and Continue button. You should see the following screen:
Jenkins provide website URL
Now, provide your Jenkins URL and click on the Save and Finish button. You should see the following screen:
Jenkins installed
Click on the Start Using Jenkins. You should see the Jenkins Dashboard on the following screen:
Jenkins Dashboard

Conclusion

Congratulations! You have successfully installed Jenkins with Nginx as a reverse proxy on RockyLinux 8. You can now implement Jenkins in your development environment and automate the development process. Get started with Jenkins today on a dedicated server from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Python 3.10 on Rocky Linux 8
How to Install TaskBoard on Rocky Linux 8
How to Set Up Pritunl VPN Server on Rocky Linux 8
How to Install Teampass Password Manager on Rocky Linux 8
How to Install and Configure RabbitMQ Server on Rocky Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources