Nirmalya Mondal
Posted on February 18, 2024
Jenkins is a powerful open-source automation server that facilitates continuous integration and continuous delivery (CI/CD). Installing Jenkins on an EC2 instance is a common choice for those seeking flexibility and scalability. This guide provides a step-by-step process that ensures a reliable installation, suitable for various scenarios.
Prerequisites
Before diving into the installation, ensure that you have the following:
- An AWS account with appropriate permissions to create and manage EC2 instances.
- Basic knowledge of AWS services and EC2 concepts.
- An EC2 instance running a compatible Linux distribution (Ubuntu is recommended).
Step 1: Launch an EC2 Instance
- Log in to AWS Console:
- Access the AWS Management Console and navigate to the EC2 dashboard.
- Launch EC2 Instance:
- Click on "Launch Instance" and choose an Amazon Linux 2 AMI or your preferred Linux distribution.
- Configure Instance:
- Select an instance type based on your requirements.
- Configure instance details, add storage, and configure security groups.
- Ensure that port 8080 is open in the security group to allow Jenkins access.
- Review and Launch:
- Review your configuration and launch the instance.
- Choose an existing key pair or create a new one to access the instance securely.
Step 2: Connect to the EC2 Instance
Use SSH to connect to your EC2 instance:
ssh -i your-key-pair.pem ec2-user@your-ec2-instance-ip
Step 3: Update the System and Install JAVA
Update the package lists and install necessary dependencies:
sudo apt update
sudo apt-get install fontconfig openjdk-17-jre
Step 4: Install Jenkins
This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system (for the Weekly Release Line):
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
Step 5: Add Jenkins Repository
Then add a Jenkins apt repository entry:
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
Step 6: Update Package and Install Jenkins
Update your local package index:
sudo apt-get update
sudo apt-get install jenkins
Step 7: Access Jenkins Web Interface
Open your web browser and navigate to http://your-ec2-instance-ip:8080
. Retrieve the initial Jenkins admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the Jenkins web interface to unlock.
Step 8: Install Recommended Plugins
Choose "Install suggested plugins" to install the default plugins or select specific plugins according to your needs.
Step 9: Create Admin User
After the plugins are installed, create an admin user and set up Jenkins according to your preferences.
Step 10: Start Using Jenkins
You now have Jenkins installed and configured on your EC2 instance. Explore Jenkins, create jobs, and automate your workflows!
Note: For enhanced security, consider configuring HTTPS using a reverse proxy like Nginx or Apache. Always refer to the Jenkins documentation for the latest and most accurate information.
By following these steps, you've established a robust Jenkins installation on your EC2 instance, setting the foundation for efficient CI/CD pipelines.
Posted on February 18, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
September 16, 2024