How to install Jenkins?
Step 1: Install Java
1. Check if you already have Java installed on your Ubuntu system:
# java -version
2. First, open a terminal window and update the system package repository by running:
# sudo apt update
3. Depending on which Java version you want to install Java 11, run one of the following commands:
# sudo apt-get install openjdk-11-jdk
Step 2: Add Jenkins Repository
1. Start by importing the GPG key. The GPG key verifies package integrity but there is no output. Run:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
2. Add the Jenkins software repository to the source list and provide the authentication key:
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 3: Install Jenkins
sudo apt-get upgrade
sudo apt-get update
Then install,
sudo apt-get install jenkins -y
3. To check if Jenkins is installed and running, run the following command:
sudo systemctl status jenkins
Step 4: Modify Firewall to Allow Jenkins
1. Open port 8080 by running the following commands:
sudo ufw allow 8080
sudo ufw status
sudo ufw enable
Step 5: Set up Jenkins
1. Open a web browser, and navigate to your server’ IP address. Use the following syntax:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword