This guide walks you through installing Jenkins on an AWS EC2 instance running Ubuntu.
Overview
Jenkins will be installed on an AWS EC2 Ubuntu instance to serve as your CI/CD automation server. This setup enables you to automate the build, test, and deployment process for your Node.js application.
Installation Steps
Update System Packages
Connect to your EC2 instance via SSH and update the package list:sudo apt update
sudo apt upgrade -y
Install Java
Jenkins requires Java to run. Install OpenJDK 11 or 17:sudo apt install openjdk-11-jdk -y
Verify the installation: Add Jenkins Repository
Add the Jenkins repository key and source:curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
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
Install Jenkins
Update the package list and install Jenkins:sudo apt update
sudo apt install jenkins -y
Start Jenkins Service
Enable and start the Jenkins service:sudo systemctl enable jenkins
sudo systemctl start jenkins
Check the service status:sudo systemctl status jenkins
Configure Security Group
In your AWS console, configure the security group for your EC2 instance to allow inbound traffic:
- Port 8080: Jenkins web interface
- Port 80: Application access
Ensure you restrict access to port 8080 to trusted IP addresses for security purposes.
Access Jenkins
Open your browser and navigate to:http://<your-ec2-public-ip>:8080
Retrieve the initial admin password:sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Complete Setup Wizard
- Enter the initial admin password
- Click “Install suggested plugins” or select specific plugins
- Create your first admin user
- Configure the Jenkins URL
- Click “Start using Jenkins”
Install Required Plugins
After completing the initial setup, install the following plugins for the CI/CD pipeline:
Navigate to Plugin Manager
Go to Manage Jenkins > Manage Plugins > Available
Install Plugins
Search for and install:
- Docker - For Docker integration
- Pipeline - For pipeline functionality
- GitHub Integration - For GitHub webhook support
Click “Install without restart” or “Download now and install after restart” Restart Jenkins
Restart Jenkins to activate the plugins:sudo systemctl restart jenkins
The Pipeline plugin may already be installed with the suggested plugins during initial setup.
Next Steps
With Jenkins installed, proceed to Docker Configuration to set up Docker permissions for the Jenkins user.