- EC2 Instance: Ubuntu 24.04 installed.
- Security Group: Ensure ports
8080
(Jenkins) and22
(SSH) are open. - Root or sudo access.
- Open your terminal and connect to your EC2 instance using SSH:
ssh -i <your-aws-key.pem> ubuntu@<ec2-instance-public-ip>
- Update the package lists:
sudo apt update
- Upgrade the system packages:
sudo apt upgrade -y
Jenkins requires Java to run. Install OpenJDK 17 (recommended version for Jenkins):
- Install OpenJDK:
sudo apt install openjdk-17-jdk -y
- Verify Java installation:
java -version
- Import the Jenkins GPG key:
wget -O /usr/share/keyrings/jenkins-keyring.asc \ https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
- Add the Jenkins package repository to the system:
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
- Update the package list to include Jenkins:
sudo apt update
- Install Jenkins:
sudo apt install jenkins -y
- Start the Jenkins service:
sudo systemctl enable jenkins
- Enable Jenkins to start at boot:
sudo systemctl start jenkins
- Allow port
8080
for Jenkins if UFW (Uncomplicated Firewall) is enabled:sudo ufw allow 8080
- Check the status of UFW:
sudo ufw status
- Open a browser and navigate to:
http://<ec2-instance-public-ip>:8080
- Retrieve the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Copy the password and paste it into the Jenkins web interface to unlock Jenkins.
- Once logged in, select the Install suggested plugins option to install the recommended Jenkins plugins.
- After the plugins are installed, you will be prompted to create the first admin user. Fill in the required details and continue.
- After completing the setup steps, Jenkins is ready to use.
- You can now access the Jenkins dashboard at:
http://<ec2-instance-public-ip>:8080