Install Jenkins on Ubuntu
Update the System
Update the package index on your Ubuntu system.
sudo apt update
Install Java
Jenkins requires Java to run. Install OpenJDK using the following command:
sudo apt install openjdk-11-jdk -y
You can verify the Java installation by checking the version.
java -version
Add Jenkins Repository
To install the latest stable Jenkins, you need to add the Jenkins repository to your system. Import the GPG key first.
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
Then add the Jenkins repository to your system:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
Install Jenkins
Update your system again after adding the repository.
sudo apt update
Install Jenkins now
sudo apt install jenkins -y
Start and Enable Jenkins
Once installed, start the Jenkins service.
sudo systemctl start jenkins
Enable the Jenkins service to start automatically on system boot.
sudo systemctl enable jenkins
Adjust Firewall
If you are using a firewall, open port 8080 (the default Jenkins port) so Jenkins can be accessed.
sudo ufw allow 8080
sudo ufw reload
Access Jenkins
Jenkins runs on port 8080 by default. You can access it by visiting the following URL in your web browser.
http://your_server_ip_or_domain:8080
Unlock Jenkins
When you first access Jenkins, you will be prompted to unlock it.
To get the initial admin password and run.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the Jenkins interface.
Install Suggested Plugins and Create Admin User
Jenkins will prompt you to install suggested plugins. Click on Install suggested plugins.
Once the installation completes, create an admin user.
That's it! Jenkins is now installed and running on your Ubuntu system.