Jenkins is one of the most widely used open-source automation servers in the DevOps world. It builds, tests, and deploys your code every time a change is pushed, which removes slow and error-prone manual releases. In this guide you will learn how to install Jenkins on Ubuntu 24.04, complete the initial setup, and create your first declarative pipeline from scratch.
If you have previously automated builds with GitHub Actions, Jenkins gives you a self-hosted alternative that runs entirely on your own server, with thousands of plugins for almost every tool in your stack.
Prerequisites – How to Install Jenkins on Ubuntu
- A server or VPS running Ubuntu 24.04 with at least 2 GB of RAM (4 GB recommended).
- A user account with sudo privileges.
- Ports 8080 open in your firewall if you want to reach the web interface from outside.
- Basic familiarity with the Linux command line.
Step 1: Install Java Before You Install Jenkins on Ubuntu 24.04
Jenkins is written in Java, and current Jenkins LTS releases require Java 17 or Java 21. Ubuntu 24.04 ships OpenJDK 21 in its default repositories, so installation is straightforward:
sudo apt update
sudo apt install -y openjdk-21-jre fontconfig
java -version
The last command should print the installed OpenJDK version. If Java is missing, Jenkins will refuse to start, so always verify this step before continuing.

Step 2: Add the Jenkins Repository and Install the Package – How to Install Jenkins on Ubuntu
The Jenkins project maintains its own Debian repository, which gives you the long-term support (LTS) release and regular security updates through APT:
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
sudo apt update
sudo apt install -y jenkins
Once the package is installed, enable and start the service:
sudo systemctl enable --now jenkins
sudo systemctl status jenkins
You should see the service in an active (running) state. If you use UFW, allow the web interface port:
sudo ufw allow 8080/tcp
Step 3: Unlock Jenkins and Install Suggested Plugins
Open your browser and visit http://YOUR_SERVER_IP:8080. Jenkins asks for an initial admin password, which is stored on the server:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Paste that password into the setup wizard, choose Install suggested plugins, and wait for the installation to finish. Then create your first admin user with a strong password. This one-time setup is the part most people forget when they install Jenkins on Ubuntu 24.04 in a hurry, and the wizard cannot be skipped, so keep the password safe until the admin account exists.
Step 4: Create Your First Declarative Pipeline
A pipeline describes your entire build process as code in a file called a Jenkinsfile. To experiment quickly, use an inline pipeline script:
- On the dashboard, click New Item, enter a name such as my-first-pipeline, select Pipeline, and click OK.
- Scroll to the Pipeline section and paste the script below.
- Click Save, then Build Now.
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building the application...'
sh 'uname -a'
}
}
stage('Test') {
steps {
echo 'Running automated tests...'
}
}
stage('Deploy') {
steps {
echo 'Deploying to the server...'
}
}
}
post {
success {
echo 'Pipeline finished successfully.'
}
failure {
echo 'Pipeline failed. Check the console output.'
}
}
}
Open the build from the left-hand build history and click Console Output to watch each stage run. In a real project you would store this Jenkinsfile in your Git repository and configure the job as Pipeline script from SCM, so every commit automatically uses the same definition.
Troubleshooting Common Problems
Jenkins fails to start
Check the logs with sudo journalctl -u jenkins -e. The most common cause is a missing or incompatible Java version. Confirm that java -version reports 17 or 21.
Port 8080 is already in use
Another service is listening on the port. Find it with sudo ss -tulpn | grep 8080, or change the Jenkins port in /etc/default/jenkins (the HTTP_PORT variable) and restart the service.
The web interface is unreachable
Make sure the service is running, the firewall allows port 8080, and, on cloud servers, that the provider’s security group also allows inbound traffic on that port.
Best Practices for a Healthy Jenkins Server
Once your first pipeline runs, a few habits keep Jenkins reliable as usage grows. Build on agents, not the controller: the controller should schedule work, while separate agent nodes execute builds, which improves both security and scalability. Keep pipelines as code: store every Jenkinsfile in version control so changes are reviewed like application code. Manage credentials centrally with the Credentials plugin and folder-scoped permissions instead of plaintext values in scripts. Back up JENKINS_HOME (jobs, configuration, and credentials) on a schedule, and test the restore once; a backup you have never restored is a hope, not a plan. Finally, update Jenkins LTS and plugins regularly, ideally monthly, and read the upgrade notes because plugin ecosystems move quickly. Teams that treat Jenkins itself like production software, with the same patching and monitoring discipline as any other server, rarely suffer the “CI is down again” outages that give automation a bad name.
Conclusion
You now know how to install Jenkins on Ubuntu 24.04, unlock the dashboard, and run a declarative pipeline with build, test, and deploy stages. From here you can connect Jenkins to your Git repositories, add build agents, and combine it with the Docker workflow described in our guide on building a CI/CD pipeline with GitHub Actions and Docker. For deeper configuration options, plugin documentation, and pipeline syntax references, see the Jenkins official documentation.