Setup a Jenkins Build Server on AWS EC2

In this tutorial, you will learn how to setup a Jenkins Build Server on AWS EC2.


1. AWS EC2 instance is running. (Follow here).

2. Connect to your EC2 instance with SSH. (Follow here).

Steps to Download and Install Jenkins:

1. Run the following command to update all software packages on ec2 instance.

sudo yum update

2. Add the Jenkins repo using the following command:

sudo wget -O /etc/yum.repos.d/jenkins.repo

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

sudo rpm --import

4. Install Jenkins:

sudo yum install jenkins -y

5. Start Jenkins as a service:

sudo service jenkins start

If you get the below error while starting the jenkins service, then run the following command to update java on EC2:

sudo amazon-linux-extras install java-openjdk11

Run the command again to start Jenkins service.

Jenkins is now installed and running on your EC2 instance.

Modify EC2 Security Group:

1. Go to EC2 Dashboard.

2. Go to Security Groups and select the security group associated with EC2 instance. (Ex: demo-security-group)

3. Click on Edit Inbound Rules.

4. Click Add Rule, and then choose Custom TCP Rule from the Type list. Under Port Range enter 8080.

Configure Jenkins:

1. Connect to http://<ec2-server-public-dns>:8080 from your  browser. You will be able to access Jenkins through its management interface.

2. Enter the password found in /var/lib/jenkins/secrets/initialAdminPassword. Use the following
command to display this password:

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

3. The Jenkins installation script directs you to the Customize Jenkins page. Click Install suggested plugins.

4. Create a new Admin User and complete the setup.

5. Click Start Using Jenkins.

Jenkins Build Server is ready to be used on the AWS EC2 server.

NEXT: Setup Jenkins Master Slave Configuration In AWS



Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

Leave a Reply

Your email address will not be published.