How To Install Jenkins on Amazon Linux 2

Jenkins is a free to use and open source automation server written in Java. It is created to enable developers around the world to reliably build, test, and deploy their software of any kind. Jenkins is designed to be modular and you can easily extend its functionality by developing your own Jenkins plugins.

This guide will cover all the steps required to install and run Jenkins Server on Amazon Linux 2 and secure it with Let’s Encrypt SSL certificate. By the end of this article you should have a working Jenkins server and ready to automate all sorts of tasks related to building, testing, and delivering or deploying software.

As there are many ways of installing Jenkins, mainly native system packages, Docker, or running is a standalone on any machine with a Java Runtime Environment (JRE) installed. We will be focusing on the package installation method as it is the easiest and most convenient method.

These are the minimum hardware requirements for installing Jenkins on Amazon Linux 2 server.

  • 256 MB of RAM, 1 GB+ recommended
  • 1 CPU core at minimum
  • 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)

Step 1: Update Amazon Linux 2 server

Start an SSH session to your Amazon Linux 2 server.

$ ssh [email protected]
Warning: Permanently added '192.168.1.184' (ECDSA) to the list of known hosts.
Enter passphrase for key '/Users/cloudspinx/.ssh/id_rsa':

       __|  __|_  )
       _|  (     /   Amazon Linux 2
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
10 package(s) needed for security, out of 24 available
Run "sudo yum update" to apply all updates.
[cloudspinx@AmazonLinux ~]$

Let’s make sure our Amazon Linux 2 server is up-to-date.

sudo yum -y update

Perform a system reboot after the upgrade is done.

sudo systemctl reboot

Step 2: Install Java on Amazon Linux 2

Jenkins main requirement is Java runtime environment. Java packages are available to Amazon Linux through correto. We will install OpenJDK 17 in the server.

sudo yum install java-17-amazon-corretto

Hit the y key in your keyboard when asked before installation commences.

...
Transaction Summary
==================================================================================================================================================================
Install  1 Package (+31 Dependent packages)

Total download size: 46 M
Installed size: 183 M
Is this ok [y/d/N]: y

Confirm installation by checking the Java version.

$ java --version
openjdk 17.0.13 2024-10-15 LTS
OpenJDK Runtime Environment Corretto-17.0.13.11.1 (build 17.0.13+11-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.13.11.1 (build 17.0.13+11-LTS, mixed mode, sharing)

Step 3: Add Jenkins repository

I had stated earlier that we’ll use the package installation method. In this method a package repository is required which can be added by running the following command in the terminal.

sudo tee /etc/yum.repos.d/jenkins.repo<<EOF
[jenkins]
name=Jenkins
baseurl=http://pkg.jenkins.io/redhat
gpgcheck=0
EOF

Import GPG repository key.

sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

Update the list of repositories to confirm it is working.

$ sudo yum repolist
Loaded plugins: langpacks, priorities, update-motd
jenkins                                                                                                                       | 2.9 kB  00:00:00     
jenkins/primary_db                                                                                                            | 222 kB  00:00:03     
repo id                                                               repo name                                                                status
amzn2-core/2/x86_64                                                   Amazon Linux 2 core repository                                           36,826
amzn2extra-docker/2/x86_64                                            Amazon Extras repo for docker                                               137
amzn2extra-java-openjdk11/2/x86_64                                    Amazon Extras repo for java-openjdk11                                       314
jenkins                                                               Jenkins                                                                     815
repolist: 38,092

Step 4: Install Jenkins Server on Amazon Linux 2

The final step is the actual installation of Jenkins Server in Amazon Linux 2 system.

sudo yum install -y jenkins

Accept to start the installation of Jenkins on Amazon Linux 2 server.

Loaded plugins: langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.495-1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================
 Package                            Arch                              Version                               Repository                          Size
=====================================================================================================================================================
Installing:
 jenkins                            noarch                            2.495-1.1                             jenkins                             90 M

Transaction Summary
=====================================================================================================================================================
Install  1 Package

Total download size: 90 M
Installed size: 90 M
Downloading packages:
jenkins-2.495-1.1.noarch.rpm                                                                                                  |  90 MB  00:00:15     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jenkins-2.495-1.1.noarch                                                                                                          1/1 
  Verifying  : jenkins-2.495-1.1.noarch                                                                                                          1/1 

Installed:
  jenkins.noarch 0:2.495-1.1                                                                                                                         

Complete!

Start and enable the jenkins service to start at the OS boot.

sudo systemctl start jenkins
sudo systemctl enable jenkins

Confirm the service is running and set to autostart.

$ 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 Mon 2025-02-03 17:33:45 UTC; 38s ago
 Main PID: 12798 (java)
   CGroup: /system.slice/jenkins.service
           └─12798 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080

Feb 03 17:33:38 amazonlinux.cloudspinx.com jenkins[12798]: *************************************************************
Feb 03 17:33:38 amazonlinux.cloudspinx.com jenkins[12798]: *************************************************************
Feb 03 17:33:38 amazonlinux.cloudspinx.com jenkins[12798]: *************************************************************
Feb 03 17:33:45 amazonlinux.cloudspinx.com jenkins[12798]: 2025-02-03 17:33:45.766+0000 [id=33]        INFO        jenkins.InitReactorRunner...zation
Feb 03 17:33:45 amazonlinux.cloudspinx.com jenkins[12798]: 2025-02-03 17:33:45.786+0000 [id=23]        INFO        hudson.lifecycle.Lifecycl...unning
Feb 03 17:33:45 amazonlinux.cloudspinx.com systemd[1]: Started Jenkins Continuous Integration Server.

$ systemctl is-enabled jenkins
enabled

The Jenkins service will bind to port 8080 by default.

$ sudo ss -tunelp | grep 8080
tcp   LISTEN 0      50                 *:8080            *:*    users:(("java",pid=12798,fd=8)) uid:996 ino:35960 sk:d v6only:0 <->

Step 5: Access Jenkins Server on Amazon Linux 2

If the service was started successfully the Web console can be accessed on:

 http://[serverip_ip_or_hostname]:8080

The default login password is store in this file:

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
7c893b9829dd4ba08244ad77fae9fe4f

Copy the password from the said location and paste it in the box.

Agree to install suggested Plugins which extends Jenkins with additional features to support many different needs.

Wait for the plugins to be installed:

Once the plugins are installed create first admin user.

Jenkins Instance access URL will be printed in the screen that follows. This can be changed with a valid DNS name.

Finish the setup to start using Jenkins. For more reading on configurations refer to official Jenkins Documentation.

Learn more about how we can support your journey with CloudSpinx.

More articles on Amazon Linux 2.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

One of the most effective control panels for web hosting that is used to host websites and administer web servers […]

Beekeeper Studio is an open-source completely free cross-platform SQL editor and database manager. It is available for Mac, Linux, and […]

OpenResty® is a full-featured web platform that uses our improved Nginx core to scale online applications and services. Its purpose […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.