Jenkins on AWS Cloud ☁

rishabhsharma
5 min readMay 9, 2023

--

Hello folks👋🏻,

In this article we will be looking at how to install and configure Jenkins over AWS Cloud on EC2 Instance.

Jenkins is an open-source automation server that integrates with a number of AWS Services, including: AWS CodeCommit, AWS CodeDeploy, Amazon EC2 Spot, and Amazon EC2 Fleet. Here we will see how we can install Jenkins on EC2 Instance.

Prerequisites

  1. An AWS Account
  2. Putty to ssh into ec2 instance
  3. And a big smile on your face😊

Let’s get started!

Creating a security group

EC2 > Security Groups > Create security group

Inbound Rules: Allow SSH, HTTP and Port 8080 (default) for Jenkins

Launching an EC2 Instance

EC2 > Instances > Launch an Instance

Here, we will be using Amazon Linux AMI

Instance type as t2.micro (free-tier)

Create a new key pair -> .pem file will get download

Use Puttygen to convert .pem to .ppk format which will be required to SSH into ec2 instance using Putty.

Select created security group(jenkins)

Click on Launch instance

Our Instance is up & running

Now that the Amazon EC2 instance has been launched, Jenkins can be installed & configured properly.

Steps to follow :

Connecting EC2 instance using Putty

There is a default user named ec2-user. We will be using it to ssh into ec2 instance.

Open Putty

1 ) Hostname (or IP address) as ec2-user@Public-IP

2 ) On left panel go to Connection > SSH > Auth

3 ) At private key file for Authentication browse your .ppk file

4) Click Open then Accept

We will get connected to our ec2 instance

Installing Jenkins

Completing the previous steps enables you to download and install Jenkins on AWS.

To download and install Jenkins:

1 ) Ensure that your software packages are up to date on your instance by using the following command to perform a quick software update:

[ec2-user@ip ~]$ sudo yum update –y

2 ) Add the Jenkins repo using the following command:

[ec2-user@ip ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo

3 ) Import a key file from Jenkins-CI to enable installation from the package:

[ec2-user@ip ~]$ sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

4 ) Install Java (Amazon Linux 2023):

[ec2-user@ip ~]$ sudo dnf install java-11-amazon-corretto -y

5 ) Install Jenkins

[ec2-user@ip ~]$ sudo yum install jenkins -y

6 ) Enable the Jenkins service to start at boot:

[ec2-user@ip ~]$ sudo systemctl enable jenkins

7 ) Start Jenkins as a service

[ec2-user@ip ~]$ sudo systemctl start jenkins

You can check the status of the Jenkins service using the command:

[ec2-user@ip ~]$ sudo systemctl status jenkins

Configuring Jenkins

Jenkins is now installed and running on your EC2 instance. To configure Jenkins:

  1. Connect to http://<your_server_public_ip>:8080 from your browser.

You will be able to access Jenkins:

2. As prompted, enter the password found in /var/lib/jenkins/secrets/initialAdminPassword

[ec2-user@ip ~]$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Provide Password -> Click Continue

3 . You will be prompted to Customize Jenkins Page. Click Install suggested plugins.

4. Once the installation is complete, the Create First Admin User will open. Enter your information, and then select Save and Continue.

Instance Configuration -> select Save and Finish.

Jenkins is ready!

Jenkins setup is complete. click Start using Jenkins

Here is how Jenkins Dashboard look like!

Let’s create a simple Job:

1 ) Click Create a Job

2 ) Enter an item name -> select Freestyle project -> click OK

3 ) Configure

Go down to Build Steps -> select Execute Shell

4 ) click Save

5 ) Now we can build this Job

6) Click on Build Now -> After Job build successfully -> Click on Job -> select Console Output

We have successfully setup Jenkins over AWS Cloud!!

⚡Happy Learning! Keep Growing!

--

--

rishabhsharma

AWS Certified ☁️ | PySpark | DevOps | Machine Learning 🧠 | Kubernetes ☸️ | SQL 🛢