How To Install Jenkins on Amazon Linux 2

Posted on 249 views

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 '' (ECDSA) to the list of known hosts.
Enter passphrase for key '/Users/jkmutai/.ssh/id_rsa':

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
10 package(s) needed for security, out of 24 available
Run "sudo yum update" to apply all updates.
[[email protected] ~]$

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 in the system upstream repositories.

We will install OpenJDK 11 in the server.

sudo amazon-linux-extras install java-openjdk11

Hit the 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 11.0.7 2020-04-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10-LTS, mixed mode, sharing)

Step 3: Add Jenkins repository to Amazon Linux 2 server

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<

Import GPG repository key.

sudo rpm --import

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                                                                                                                         | 161 kB  00:00:00
repo id                                                                     repo name                                                                       status
amzn2-core/2/x86_64                                                         Amazon Linux 2 core repository                                                  22,852
amzn2extra-docker/2/x86_64                                                  Amazon Extras repo for docker                                                       36
amzn2extra-java-openjdk11/2/x86_64                                          Amazon Extras repo for java-openjdk11                                               64
jenkins                                                                     Jenkins                                                                            596

Step 4: Install Jenkins Server on Amazon Linux 2 server

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

sudo yum install jenkins

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

Dependencies Resolved

 Package                               Arch                                 Version                                   Repository                             Size
 jenkins                               noarch                               2.270-1.1                                 jenkins                                67 M

Transaction Summary
Install  1 Package

Total size: 67 M
Installed size: 68 M
Is this ok [y/d/N]: y

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

$ sudo systemctl start jenkins

$ sudo systemctl enable jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on

Confirm the service is running and set to autostart.

$ systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Wed 2020-12-09 17:52:04 UTC; 9s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2911 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/jenkins.service
           └─2932 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenki...

Dec 09 17:52:03 amazon-linux systemd[1]: Starting LSB: Jenkins Automation Server...
Dec 09 17:52:03 amazon-linux runuser[2916]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Dec 09 17:52:04 amazon-linux jenkins[2911]: Starting Jenkins [  OK  ]
Dec 09 17:52:04 amazon-linux systemd[1]: Started LSB: Jenkins Automation Server.

$ systemctl is-enabled jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins --level=5

The Jenkins service will bind to port 8080 by default.

$ sudo ss -tunelp | grep 8080
tcp  LISTEN 0      50                                     *:8080              *:*          users:(("java",pid=2932,fd=139)) uid:996 ino:26048 sk:f v6only:0 <->

Step 5: Access Jenkins Server on Amazon Linux 2

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


The default login password is store in this file:

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

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.


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

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.