On this page
- What do you need before installing Jenkins?
- How do you install Jenkins on Ubuntu and Debian?
- How do you install Jenkins on Rocky Linux and AlmaLinux?
- How do you unlock Jenkins and finish the wizard?
- How do you put Jenkins behind HTTPS?
- Why should builds run on agents instead of the controller?
- How do you write a first pipeline?
- How do you back up and upgrade Jenkins?
- Questions
What do you need before installing Jenkins?
Jenkins needs a supported Java runtime, about 2 GB of memory for the controller on its own and disk space for build history and workspaces. Current LTS releases run on Java 21, which is the safe choice for a new install in late 2026.
- Ubuntu 24.04 and 22.04:
openjdk-21-jre-headlessis in the archive. - Debian 13:
openjdk-21-jre-headlessis in main. - Debian 12: main only carries Java 17, so either use Debian 13 for a new server or add the Eclipse Temurin repository for a Java 21 build.
- Rocky Linux 9 and AlmaLinux 9:
java-21-openjdkis in AppStream.
Builds compile code, pull containers and fill workspaces, so pick the plan by the heaviest job you expect. A DNS name such as ci.example.net pointing at the server (see DNS records) saves time when you add HTTPS.
How do you install Jenkins on Ubuntu and Debian?
Add the signing key and the stable (LTS) repository, then install Java and Jenkins together.
sudo apt update
sudo apt install -y fontconfig openjdk-21-jre-headless wget
sudo install -d -m 0755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/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
java -version
systemctl status jenkins --no-pagerThe project rotates its repository key from time to time. If apt update reports a missing or expired key, open https://pkg.jenkins.io/debian-stable/ and use the key file name listed there.
How do you install Jenkins on Rocky Linux and AlmaLinux?
On the RHEL family, fetch the repository file, import the key and install with dnf.
sudo dnf install -y wget fontconfig java-21-openjdk
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo dnf install -y jenkins
sudo systemctl daemon-reload
sudo systemctl enable --now jenkins
rpm -q jenkinsIf several Java versions are installed, select 21 with sudo alternatives --config java before starting the service.
How do you unlock Jenkins and finish the wizard?
Read the one time key from disk and paste it into the setup page. Until the proxy is ready, reach the page through an SSH tunnel instead of opening port 8080 to the world:
# on your own computer
ssh -L 8080:127.0.0.1:8080 deploy@198.51.100.24
# on the server
sudo cat /var/lib/jenkins/secrets/initialAdminPasswordBrowse to http://localhost:8080, paste the key, choose Install suggested plugins (or pick a smaller set) and create your own admin account. Set the Jenkins URL to the final HTTPS address, for example https://ci.example.net/, so links in mails and webhooks are right.
How do you put Jenkins behind HTTPS?
Bind Jenkins to the loopback address with a systemd override, then let a reverse proxy terminate TLS. The package reads its port and listen address from environment variables:
sudo systemctl edit jenkins
# add between the comment lines:
[Service]
Environment="JENKINS_LISTEN_ADDRESS=127.0.0.1"
Environment="JENKINS_PORT=8080"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Xmx1g"
sudo systemctl restart jenkins
ss -tlnp | grep 8080The ss output should now show 127.0.0.1:8080. A Caddy block such as ci.example.net { reverse_proxy 127.0.0.1:8080 } gives you a certificate automatically (Caddy HTTPS); with Nginx follow the reverse proxy guide and keep the Host and X-Forwarded-Proto headers, or Jenkins warns that the reverse proxy setup is broken. Allow only SSH, 80 and 443 in ufw or firewall-cmd.
Why should builds run on agents instead of the controller?
A build running on the controller can read Jenkins secrets and configuration, so the project advises setting the controller to zero executors and running jobs on agents. Under Manage Jenkins, Nodes, Built-In Node set Number of executors to 0. Then add an agent:
- SSH agent: a second server (or a separate user on the same one) with Java 21; Jenkins connects over SSH with a key you store as a credential.
- Inbound agent: the agent opens the connection to the controller, useful when the agent sits behind NAT.
- Docker agents: with the Docker plugin and Docker Engine, each build gets a fresh container.
A small controller plus one or two build servers is a common split; the CI runners page explains how plans map to build load.
How do you write a first pipeline?
Keep the pipeline in a Jenkinsfile at the repository root so it is versioned with the code. A minimal declarative example:
pipeline {
agent any
options { timeout(time: 20, unit: 'MINUTES') }
stages {
stage('Test') {
steps { sh 'make test' }
}
stage('Package') {
when { branch 'main' }
steps { sh 'make dist' }
}
}
post {
always { archiveArtifacts artifacts: 'dist/**', allowEmptyArchive: true }
}
}Create a Multibranch Pipeline job pointing at the repository and Jenkins discovers every branch that contains a Jenkinsfile.
How do you back up and upgrade Jenkins?
Everything Jenkins knows lives in /var/lib/jenkins: jobs, plugins, credentials and the secret keys that decrypt them. Back up the whole directory, or at least everything except workspace and old build logs.
sudo systemctl stop jenkins
sudo tar --exclude='workspace' -czf /root/jenkins-home.tar.gz -C /var/lib jenkins
sudo systemctl start jenkinsUpgrades arrive through the package manager (sudo apt upgrade jenkins or sudo dnf upgrade jenkins). Read the LTS upgrade notes first, update plugins from Manage Jenkins, Plugins afterwards and restart. The disk wide daily backup add-on is a good safety net alongside the tarball, see daily backups.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Jenkins automation server
Jenkins does not start after install, what now?
Run journalctl -u jenkins -n 80. The usual causes are a missing or too old Java runtime, or another service already using port 8080.
How do I change the Jenkins port?
Set JENKINS_PORT in a systemctl edit jenkins override and restart. Editing /etc/default/jenkins no longer has an effect on systemd based packages.
Can I send build mail from Jenkins?
Use an authenticated SMTP relay on port 587 in the mail settings. Port 25 may not be open for direct delivery, so ask support with a ticket before planning on it.
Should I use the weekly or the LTS line?
LTS gets a new baseline roughly every twelve weeks with backported fixes, which suits a server you do not want to touch often. Weekly gives new features sooner.
How much memory does the controller need?
Around 2 GB serves a handful of jobs when builds run on agents. Large plugin sets or many concurrent users need 4 GB or more.