Install Jenkins on Ubuntu
Summary
Jenkins is an open-source automation server that enables developers to build, test, and deploy their software. This tutorial will guide you through installing Jenkins on Ubuntu, including Java setup, repository configuration, and initial configuration.
Key Vocabulary
Prerequisites
- Ubuntu 20.04 or later
- Sudo/root access
- Internet connection
- At least 2GB RAM recommended
Step-by-Step Instructions
Update Package Repository
Update the package repository to ensure you have the latest package information.
sudo apt update -y
Install Java 21
Install OpenJDK 21, which is required for Jenkins to run.
sudo apt install openjdk-21-jdk -y
Verify Java Installation
Check that Java is properly installed and accessible.
java -version
Download Jenkins GPG Key
Download and add the Jenkins GPG key for package verification.
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
Add Jenkins Repository
Add the official Jenkins repository to your system's package sources.
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
Update package lists to include the new Jenkins repository.
sudo apt update -y
Install Jenkins
Install the Jenkins package using apt.
sudo apt install jenkins -y
Start and Enable Jenkins
Start the Jenkins service and enable it to start automatically on boot.
sudo systemctl start jenkins && sudo systemctl enable jenkins
Check Jenkins Status
Verify that Jenkins is running properly.
sudo systemctl status jenkins
Get Initial Admin Password
Retrieve the initial administrator password for Jenkins setup.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Access Jenkins Web Interface
Open Jenkins in your web browser to complete the setup.
Common Issues & Solutions
Solution: Check if Java is properly installed with 'java -version'. Ensure you have sufficient RAM (at least 2GB recommended).
Solution: Check what service is using port 8080 with 'sudo netstat -tulpn | grep :8080' and stop the conflicting service.
Solution: Ensure your firewall allows traffic on port 8080. Use 'sudo ufw allow 8080' if using UFW.
Solution: Wait a moment for Jenkins to fully start up, then check the path again. The file is created during Jenkins startup.
Conclusion
Congratulations! You have successfully installed Jenkins on your Ubuntu system. Jenkins is now running and ready to be configured for your CI/CD pipelines.
Next steps:
- Access Jenkins at
http://your-server-ip:8080 - Use the initial admin password to complete setup
- Install recommended plugins
- Create your first admin user
- Start building your first pipeline!