JENKINS Installation
To install Jenkins for CI/CD on Ubuntu, follow these step-by-step instructions. Below, I’ll also highlight common installation issues with examples to help you troubleshoot effectively.
Step-by-Step Installation of Jenkins on Ubuntu
Update the System Ensure your package list and installed packages are up to date.
sudo apt update && sudo apt upgrade -yInstall Java Jenkins requires Java. Install OpenJDK 11, which is compatible with most Jenkins versions.
sudo apt install openjdk-11-jre -yVerify the installation:
java -versionExpected output should show Java version 11.
Add Jenkins Repository Import the GPG key and add the Jenkins repository.
curl -fsSL https://pkg.jenkins.io/debian/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 binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/nullUpdate Package List Refresh the package index to include the Jenkins repository.
sudo apt updateInstall Jenkins Install Jenkins using the apt package manager.
sudo apt install jenkins -yStart and Enable Jenkins Service Start the Jenkins service and enable it to run on boot.
sudo systemctl start jenkins sudo systemctl enable jenkinsCheck Jenkins Status Verify that Jenkins is running.
sudo systemctl status jenkinsLook for
active (running)in the output.Configure Firewall Allow traffic on port 8080 (default Jenkins port).
sudo ufw allow 8080 sudo ufw enableAccess Jenkins Web Interface Open a browser and navigate to
http://your_server_ip:8080. Retrieve the initial admin password:sudo cat /var/lib/jenkins/secrets/initialAdminPasswordEnter this password on the setup page, then follow the prompts to install plugins and create an admin user.
Complete Setup
Install suggested plugins.
Create an admin user.
Save the instance configuration (default URL is fine).
Jenkins is now installed and ready for CI/CD pipeline configuration.
Common Installation Issues with Examples
Java Not Installed or Incorrect Version
Issue: If Java is missing or an incompatible version (e.g., Java 17) is installed, Jenkins fails to start.
Example: Running
sudo systemctl status jenkinsshowsJob for jenkins.service failed because the control process exited with error code.Solution: Uninstall existing Java and install OpenJDK 11.
sudo apt remove --purge openjdk* sudo apt install openjdk-11-jre -y sudo systemctl restart jenkins
Repository Key Error
Issue: The GPG key import fails, leading to a 404 error or repository not found.
Example:
apt updateoutputsThe following signatures couldn't be verified because the public key is not available.Solution: Ensure the correct key URL is used. Retry the key import and update.
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null sudo apt update
Port 8080 Already in Use
Issue: Another service (e.g., Apache) is using port 8080, causing Jenkins to fail.
Example: Browser shows "Connection refused" or
sudo systemctl status jenkinsindicates a bind failure.Solution: Change Jenkins port or stop the conflicting service.
sudo nano /etc/default/jenkinsEdit
HTTP_PORT=8081, then restart Jenkins:sudo systemctl restart jenkins
Service Fails to Start
Issue: Insufficient permissions or misconfiguration prevents Jenkins from starting.
Example:
sudo systemctl start jenkinsfails with no clear error instatus.Solution: Check logs for details.
sudo journalctl -u jenkins.serviceEnsure the
jenkinsuser has proper permissions on/var/lib/jenkins.
Firewall Blocks Access
Issue: UFW is enabled but port 8080 is not allowed, blocking web access.
Example: Browser shows "This site can’t be reached" despite Jenkins running.
Solution: Verify and allow the port.
sudo ufw status sudo ufw allow 8080