Install Jenkins

- 3 mins read

Jenkins is an open-source automation server that helps automate the building, testing, and deployment of software projects. Jenkins is widely used for its flexibility, extensive plugin ecosystem, and strong community support, making it an excellent choice for continuous integration and continuous delivery (CI/CD) needs.

This post is a step-by-step install guide for Jenkins on Ubuntu 24.04.


1. Install Java

Since Jenkins is a Java-based application, we’ll need to install OpenJDK 17 for the latest and stable Jenkins setup. Open your terminal and execute the following commands:

$ sudo apt update
$ sudo apt install fontconfig openjdk-17-jre -y

Once Java is installed, verify the installation by running:

$ java --version

You should see the installed Java version displayed. With Java set up, we’re ready to proceed.


2. Add Jenkins APT Repository

Ubuntu 24.04’s default repositories do not include Jenkins, so we’ll add the APT repository. Run the following commands to add the Jenkins key and repository:

$ sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.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

3. Install Jenkins on Ubuntu 24.04

Now that we have the necessary repository, we can install Jenkins. Update your package list and install Jenkins with:

$ sudo apt update
$ sudo apt install jenkins -y

Jenkins should start automatically after installation. To confirm, check its status with:

$ systemctl status jenkins

If Jenkins isn’t running, start it manually:

$ sudo systemctl start jenkins

Set Jenkins service to start automatically on startup/reboot:

$ sudo systemctl enable jenkins

4. Configure Firewall Rules for Jenkins

Jenkins listens on port 8080 by default. If UFW is enabled on your server, you’ll need to allow traffic on this port.

Enable the firewall and open port 8080:

$ sudo ufw enable
$ sudo ufw allow 8080/tcp
$ sudo ufw reload

To verify the changes, check the firewall status:

$ sudo ufw status

You should see port 8080 listed as open.


5. Finish Jenkins Initial Setup

With Jenkins running, complete the initial setup via the web interface. Find your server’s IP address using the ip command.

$ ip a

Check for the adminsitrator password at /var/lib/jenkins/secrets/initialAdminPassword:

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Open your browser and go to:

http://<Your-Ubuntu-System-IP>:8080

Once the page has loaded:

  • Enter the password and click Continue.

  • Next, choose Install suggested plugins to keep things simple. Jenkins will start installing the required plugins.

  • After the plugin installation, you’ll be asked to create an Admin user. Fill in the details and click Save and Continue.

  • In the next step, Jenkins will show the default URL for your instance. Just click Save and Finish.

  • Finally, click Start using Jenkins to access the Jenkins dashboard.


6. Enable HTTPS

To enable HTTPS, open the Jenkins configuration file:

sudo vi /etc/default/jenkins

Locate the line containing JENKINS_PORT="8080" and change it to JENKINS_PORT="-1" to disable HTTP.

Enable HTTPS by finding the line JENKINS_HTTPS_PORT="" and changing it to JENKINS_HTTPS_PORT="8443".

Restart the Jenkins service to apply the changes:

sudo systemctl stop jenkins
sudo systemctl start jenkins

You should now be able to access Jenkins securely at:

https://<Your-Ubuntu-System-IP>:8443

Conclusion

You’ve have now successfully installed Jenkins on your Ubuntu 22.04 system.