How to Install Jenkins on Amazon EC2 – Amazon Linux AMI

How to Install Jenkins on Amazon EC2 – Amazon Linux AMI

April 7, 2023 Off By Elma

This Jenkins Tutorial for Beginners will help you understand the basics of Jenkins installation on Amazon EC2 if you are preparing to get your Jenkins Certification. You must enroll in the Jenkins Certification Course to learn more about Jenkins. This will help you pass the actual certification exam in the first attempt.
It is easier to pass your exam if you spend more time learning. Let’s learn how to install Jenkins on Amazon EC2 in this article. We will use Amazon Linux AMI.
Let’s first determine the environment required to install Jenkins.
Amazon Web Services (AWS), account credentials or IAM username credentials
Amazon EC2 instance with internet connection
SSH key-pair for EC2 to connect via SSH
Java installed on the instance
Let’s begin by creating an instance. In my case, I’m using Whizlabs Hands-On Labs environment for creating an EC2 instance. You can skip this step if you already have an EC2 account. Instead, connect via SSH to start downloading Jenkins.

Whizlabs offers Hands-On Labs if you need temporary AWS credentials to complete this task. I assume you already have AWS credentials. Let’s create an instance.
Step 1: Create an Amazon EC2 instance
Log in to AWS console to navigate to EC2 dashboard.

Click on “Launch Instance” to select the instance type, image type and fill in the rest of the details. I’m using Amazon Linux in my case.

Let’s create a security group. This is where we will install Jenkins. The default Jenkins installation will run on ports 8080 or 8443. To access Jenkins after installation, you need to add port 8080 to your security group. The Jenkins port can be modified later if necessary. Let’s just allow 8080 for now and launch the instance.

Download the keypair (which will be used to connect via SSH), and launch the instance.

We are done. Our EC2 instance has been successfully launched. The dashboard should show the instance status as running.

Step 2 – Download and install Jenkins on EC2 Instance
Now we have our instance. Let’s connect to this instance and install Jenkins.
You may need to use Putty to connect via SSH to the instance if you are running Windows. I’m on Mac so I will use my mac terminal to connect to the instance with the keyfile that we downloaded in the previous step.

Now we are connected to our instance, and we’re on the Linux system that we created. To update the packages, let’s run this command.
sudo yum upgradeWe need Java installed on the instance. The following command will install Java.
sudo yum install java-1.8.0-openjdkClick on yes when prompted and it will install Java. To ensure that Java is installed, run the following command.
Java -versionNow: Download the latest Jenkins packages from the Jenkins website. Jenkins 2.319.3 was the most recent version at the time this article was written.
To download the package, run the following commands.
sudo wget -O /etc/yum.repos.d/jenkins.repo
To enable installation from the downloaded package, run the following command.
sudo rpm –import the below commands which will install the Jenkins. When prompted, click yes
sudo yum install epel-releasesudo yum install java-11-openjdk-develsudo yum install jenkins
Jenkins has been successfully installed. The following command will start Jenkins:
sudo service jenkins start
If the output is marked [OK], then the Jenkins service has started and we are done with our installation.
Step 3: Access Jenkins via Browser
To access Jenkins from a browser copy the public IP address for your EC2 instance. Then, go to the port 8080.

If you’re following my instructions, you should be able see the page above. We now need to unlock Jenkins using an admin password. The following commands will retrieve the admin password:
sudo sucd /var/lib/jenkins/secrets/cat initialAdminPassword

Install the suggested plugins.

All that is required to get started with Jenkins is to create an admin user.

We hope you enjoyed this Jenkins tutorial. This article will show you how to configure Jenkins on Amazon EC2. This article covers some topics from CloudBees Jenkins certification exam syllabus. In the next articles, we will learn how to build Jenkins jobs and pipelines. Keep watching. Thank you for reading!