This blog post walks you through the process of installing Jenkins on a freshly launched EC2 instance. We'll cover everything from setting up the instance to accessing the Jenkins interface.
Prerequisites
An AWS account with access to the Management Console
Basic understanding of Linux commands
Launching the EC2 Instance
Open the AWS Management Console and navigate to the EC2 service.
Click on "Launch Instance".
Choose an Ubuntu AMI (Amazon Machine Image) version 20.04 (LTS).
Select an instance type. T2 Micro is sufficient for basic use, but you can upgrade to T2 Small if needed.
Create a new key pair for SSH access. Download the private key and keep it secure.
Configure the Security Group:
Allow inbound traffic on port 22 for SSH access.
Allow inbound traffic on port 8080 for Jenkins access.
Launch the instance.
Installing Jenkins
Connect to the EC2 instance via SSH using the downloaded private key.
Update package lists:
sudo apt update
Install Java JDK 11:
sudo apt install openjdk-11-jdk
Add the Jenkins repository key:
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
Create the Jenkins repository file:
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 package lists again:
sudo apt update
Install Jenkins:
sudo apt install jenkins
Starting and Verifying Jenkins
Check the Jenkins service status:
sudo systemctl status jenkins
The output should show Jenkins as "active (running)".
Accessing Jenkins
Open a web browser and navigate to
http://<your_public_IP>:8080
. Replace<your_public_IP>
with the actual public IP address of your EC2 instance.Locate the initial password file path from the Jenkins service status output.
Use
cat
command to view the password:cat <password_file_path>
Paste the password into the Jenkins login screen.
Installing Plugins (Optional)
Jenkins offers a wide range of plugins for various functionalities.
You can explore the available plugins and install the ones you need for your specific use case.
Creating User
After installing the plugins, we have to create a user.
In the next step, we need to configure the root URL for Jenkins.
Once done, we are ready to create our first job.
Creating Your First Job
We'll cover creating jobs (manual and pipeline) in detail in future lectures.
This blog post focuses on the installation process.
Important Notes
The public IP address of your EC2 instance will change when you stop and restart it.
Make sure to update the security group rules if you plan to access Jenkins from a different IP address.
Remember the username and password you created during the initial setup.
This blog post provides a basic understanding of installing Jenkins on an EC2 instance. We'll delve deeper into creating and managing Jenkins jobs in future posts.