How to Install Jenkins on Ubuntu Digital Ocean Droplet (Step by Step)

Jenkins is a powerful open-source automation server widely used for building, deploying, and automating projects. This step-by-step guide will walk you through the process of installing Jenkins on an Ubuntu-based DigitalOcean droplet.

Prerequisites

Before you proceed, ensure you have the following:

  1. DigitalOcean Account: Sign up for an account at DigitalOcean if you don’t have one.
  2. Ubuntu Droplet: Create a droplet running Ubuntu 22.04 (or the latest stable version). A minimum of 1GB RAM is required, but 4GB RAM and 2 CPUs are recommended for optimal performance.
  3. Root or Sudo Access: Ensure you have root or a sudo-enabled user to run administrative commands.
  4. Domain Name (Optional): If you want to access Jenkins using a custom domain, configure your domain to point to the droplet’s IP address.
  5. Basic Linux Knowledge: Familiarity with Linux commands and SSH.
  6. SSH Client: Tools like Terminal (Mac/Linux) or PuTTY (Windows) for connecting to your droplet.
  7. Firewall Rules: Ensure port 8080 (Jenkins default) is open or plan to configure your firewall during installation.

Step 1: Create a DigitalOcean Droplet

  1. Log in to your DigitalOcean account.
  2. Click on Create → Droplets.
  3. Select Ubuntu 22.04 as your operating system.
  4. Choose a droplet size (minimum 4GB RAM and 2 CPUs recommended).
  5. Set up SSH keys or use a password for authentication.
  6. Click Create Droplet.

Step 2: Update Your System

Once your droplet is up and running, connect to it using SSH:

ssh root@<your-droplet-IP>

Update the package index and upgrade installed packages:

sudo apt update && sudo apt upgrade -y

Check if Java is installed on your ubuntu machine.

If already install can skip the Step 3.

Step 3: Install Java 17

Jenkins requires Java to run. We will install OpenJDK 17:

sudo apt install openjdk-17-jdk -y

Verify the installation:

java -version

The output should show Java 17 as the installed version:

Step 4: Add the Jenkins Repository

Jenkins is not included in the default Ubuntu repositories, so you need to add the official Jenkins repository:

  1. Add the Jenkins GPG key:
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null

2. Add the Jenkins repository:

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

3. Update the package list:

sudo apt update

If none of the above steps work (Manually Download)

If none of the above steps work, you can manually download and install the .deb package for Jenkins. Here’s how:

wget -q -O jenkins.deb https://pkg.jenkins.io/debian-stable/binary/jenkins_2.414.1_all.deb

Download the Jenkins .deb package:

#install the jenkins
sudo apt install ./jenkins.deb -y

Step 5: Install Jenkins

Install Jenkins with the following command:

sudo apt install jenkins -y

Once installed, Jenkins will automatically start as a service.

Step 6: Configure the Firewall

To allow external access to Jenkins, open port 8080 on your firewall:

Allow OpenSSH to prevent being locked out:

sudo ufw allow OpenSSH

Allow Jenkins traffic:

sudo ufw allow 8080

Enable the firewall:

sudo ufw enable

Verify the firewall status:

sudo ufw status

Step 7: Start and Enable Jenkins

Ensure Jenkins starts automatically after a reboot:

sudo systemctl start jenkins
sudo systemctl enable jenkins

Check the status of Jenkins:

sudo systemctl status jenkins

Step 8: Access Jenkins Web Interface

Open a browser and navigate to:

http://<your-droplet-IP>:8080

You will see the Jenkins unlock page.

Step 9: Unlock Jenkins

To unlock Jenkins, retrieve the initial admin password from the server:

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

Copy the password, paste it into the web interface, and click Continue.

Step 10: Configure Jenkins

  1. Install Plugins: Select Install suggested plugins for the default set of plugins.
  2. Create Admin User: Set up an admin user with your credentials.
  3. Set Jenkins URL: Configure the Jenkins URL (e.g., http://<your-droplet-IP>:8080) and save.

Conclusion

You have successfully installed Jenkins on an Ubuntu DigitalOcean droplet with Java 17. Jenkins is now ready to automate your CI/CD workflows and manage your builds.

If you encounter any issues or need advanced configurations, refer to the official Jenkins documentation. Happy automating!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top