DEV Community

Cover image for Installing Jenkins on Amazon EC2

Installing Jenkins on Amazon EC2

Prerequisite: You will need to have an Amazon account

Log into your amazon account and launch and EC2 instance. I chose the free tier here and launched the EC2 instance will be running Amazon Linux 2. I have a detailed article on how to launch and EC2 machine here.

Knowing that Jenkins is a Java based application, we need to make sure that we have Java also installed on our Amazon EC2 instance. Only after that, we can proceed with the Jenkins installation.
Jenkins runs on port number 8080 so make sure you have the custom TCP Port 8080 open.

Security Group
I’m using MobaXterm to SSH into my EC2 instance, but you are free to use whatever tool you like. Start and SSH session, enter your remote host IP, user name and then under advance, load your private Key

Image description
After that, your login screen should be like the one bellow

Image description

Make sure that you have root access on your EC2 instance by entering sudo su -
As mentioned above it is important to make sure that Java is installed on your EC2 instance prior to installing Jenkins and for that, go to Jenkins download page and then select your linux flavor.
Once there we are using Amazon Linux 2 so I will be selecting CentOS/Fedora/Red Hat as shown in the screen bellow https://pkg.jenkins.io/redhat-stable/

Image description

Proceed with the installation by following the instructions bellow.

First add the repository



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



Enter fullscreen mode Exit fullscreen mode

EPEL package is one of the requirement that doesn't unfortunately come with Amazon Linux 2 so we will need to install that by running the command bellow



amazon-linux-extras install epel


Enter fullscreen mode Exit fullscreen mode

After that, then install Java



amazon-linux-extras install java-openjdk11


Enter fullscreen mode Exit fullscreen mode

Then proceed finally with Jenkins installation.



yum install jenkins


Enter fullscreen mode Exit fullscreen mode

Image description

Now you have successfully installed Jenkins on your EC2 instance. The next step will be to start Jenkins with the following command bellow and access it via your EC2 public IP on port 8080



service jenkins start


Enter fullscreen mode Exit fullscreen mode

Now navigate to the highlighted link in directory to retrieve the password and you should be good to go

Image description

Now you can chose to launch your Jenkins instance with the suggested plugins or chose to install only the plugins you need

Image description

Image description

Lets keep in touch

follow me on Twitter https://twitter.com/asksouley

Great source for tech swags I found recently

https://www.etsy.com/shop/GreenStoneStickers?ref=seller-platform-mcnav&section_id=37904360

Top comments (0)