DEV Community

Cover image for Configuring Jenkins on AWS EC2 Instance
Manish R Warang
Manish R Warang

Posted on • Originally published at blog.g33kzone.com

Configuring Jenkins on AWS EC2 Instance

This post provides an overview of the steps required to install and run Jenkins Server on Amazon Linux 2. By the end of the post, we will have a working Jenkins Server ready to configure pipelines.

Jenkins can be installed in numerous ways - Native system packages, Docker, standalone executable session. This post will be focused on native package installation.

Jenkins recommends the following minimum hardware requirements for Server configuration

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

For Demo purposes, we can select the T2 micro instance type as it satisfies the above minimum criteria.

Prerequisites

  • AWS Cloud Account (Free tier will work)
  • A EC2 instance running with T2 micro for instance type
  • AWS key-pair to SSH into the EC2 instance
  • Configure firewalls (security groups) to allow SSH access into the EC2 instance

Installation Steps

Step 1. Initiate an SSH session into your Amazon Linux - EC2 instance.

Screenshot 2021-06-28 at 12.29.27 PM.png

Step 2. Update existing installed packages on the EC2 instance

sudo yum update -y
Enter fullscreen mode Exit fullscreen mode

Step 3. Install most recent Open JDK (Java ver 11). Required for Jenkins installation

sudo amazon-linux-extras install java-openjdk11 -y
Enter fullscreen mode Exit fullscreen mode

Step 4. Add Jenkins repo to Amazon Linux 2 server

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

Step 5. Import GPG Jenkins repo key

sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
Enter fullscreen mode Exit fullscreen mode

Step 6. Update list of repositories

sudo yum repolist
Enter fullscreen mode Exit fullscreen mode

Step 7. Install Jenkins in Amazon Linux 2 server

sudo yum install jenkins -y
Enter fullscreen mode Exit fullscreen mode

Step 8. Start Jenkins service

sudo systemctl start jenkins
Enter fullscreen mode Exit fullscreen mode

Step 9. Enable Jenkins service to start at OS boot

sudo systemctl enable jenkins
Enter fullscreen mode Exit fullscreen mode

Step 10. Confirm that the Jenkins Service is up and running

sudo systemctl status jenkins
Enter fullscreen mode Exit fullscreen mode

Screenshot 2021-06-28 at 12.47.13 PM.png

Step 11. Validate if the Jenkins service is configured to autostart on system reboot.

sudo systemctl is-enabled jenkins
Enter fullscreen mode Exit fullscreen mode

Screenshot 2021-06-28 at 12.51.18 PM.png

Step 12. Access Jenkins Server on EC2 instance
Jenkins service by default binds to port 8080. It will be accessible on

http://[server-ip-or-hostname]:8080
Enter fullscreen mode Exit fullscreen mode

For the first time, Jenkins will prompt the Unlock Jenkins screen to authenticate the installation.

Screenshot 2021-06-28 at 1.02.15 PM.png

Step 13. Fetch password to Unlock Jenkins.
As advised the following command will provide the relevant password

cat /var/lib/jenkins/secrets/initialAdminPassword
Enter fullscreen mode Exit fullscreen mode

Copy the automatically-generated alphanumeric password (between the 2 sets of asterisks). On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.

Step 14. Customize Jenkins
Recommended selecting Install suggested plugins to install the recommended set of plugins based on most common use cases.

Screenshot 2021-06-28 at 5.08.29 PM.png

The setup wizard shows the progression of Jenkins plugins being installed
Screenshot 2021-06-28 at 5.12.11 PM.png

Step 15. Create First Admin User
Enter relevant details to create Admin User and click ** Continue **
Screenshot 2021-06-28 at 5.13.41 PM.png

Step 16. Configure Valid DNS (if required)
Jenkins Instance access URL will be printed on the screen that follows. This can be changed with a valid DNS name. For the purpose of our demo, we will leave it unchanged and click ** Save and Finish **

Screenshot 2021-06-28 at 5.17.35 PM.png

Step 17. Jenkins is ready, Hurray!! You have now successfully configured Jenkins.
Screenshot 2021-06-28 at 5.20.58 PM.png

Jenkins Dashboard
Screenshot 2021-06-28 at 5.24.40 PM.png

Top comments (0)