- An AWS EC2 instance running Ubuntu 22.04 LTS
- Jenkins setup running on Docker
- Log in to your AWS account
- After you are logged in, select the Services button:
- Select Compute
- Select EC2 for a Virtual Private Server in the cloud
- Launch a new instance by selecting Launch Instances:
- Fill in the Name of your server, and select the Amazon Linux image
- Leave the Instance Type section as is
- In the Key Pair section, select Create key pair fill in the details, and you will be prompted to download the key .pem file, and keep it in a Folder where it's easily accessible from your terminal.
- In the Network Settings section, select Allow HTTPS traffic from the internet and Allow HTTP traffic from the internet
- Configure the storage requirements as you like, but we will be using 20 GiB gp3 configuration
- Select Launch Instance in the Summary section:
- You can now see your EC2 instance, in the Instances list:
- Port 8080 was added to the security group
- Select Connect, and choose SSH Client to get the details of the remote SSH connection.
- This is where the downloaded Identity file from the Key Pair created is needed. I opened up the terminal and:
ssh -i "Jenkins CI Server.pem" [email protected]
and connection to the EC2 instance was established.
I installed Jenkins as per the official documentation at https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/ as follows:
- Install OpenJDK Java Runtime Environment (JRE) 17:
sudo yum update –y
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-2023.key
sudo yum upgrade
sudo dnf install java-17-amazon-corretto -y
- Install Jenkins LTS:
sudo yum install jenkins -y
- Enable the Jenkins service:
sudo systemctl enable jenkins
- Start the Jenkins service:
sudo systemctl start jenkins
- That's it setting up your CI/CD server, you can now access it using the public IP
http://51.20.35.190:8080/
. NOTE: SSL has not been enabled. - You can find the administrator password at
/var/jenkins_home/secrets/initialAdminPassword
- Run:
cat /opt/jenkins/home/secrets/initialAdminPassword
and copy the contents, and paste in to the password field. - Select Install Suggested Plugins:
- As the setup progresses, you will be presented with this page:
- After the plugins installation completes, fill the Admin user information
- Choose the instance URL, we will use the public IP of the AWS instance, which will be filled in by default:
- Select start using Jenkins, and you will be signed in, and presented with the home page
After establishing an SSH connection to your EC2 instance, here is where Docker will be installed. We install docker so that it can be used with jobs that need it. In my case this were the steps followed:
- Install the Docker package:
sudo yum install docker -y
- Added the
jenkins
user to thedocker
group
sudo usermod -aG docker jenkins