Search for a command to run...
Install Jenkins 2.580 LTS on Linux, Windows, macOS, Docker and Kubernetes, configure it with Configuration as Code, add agents and build your first pipeline.
Jenkins is a self-hosted automation server. This guide installs the current Jenkins LTS line, configures it with Configuration as Code, adds build agents and runs a first pipeline.
Jenkins 2.580.1 LTS (weekly builds are also available) · Java 21 or newer is
required · the jenkins.io-2026.key signing key · jenkins/jenkins:lts-jdk21 image
Jenkins now requires Java 21 or later. Install Java before Jenkins — if the
service is installed first and Java added afterwards, the service fails to start with
jenkins: failed to find a valid Java installation.
| Component | Minimum | Recommended |
|---|---|---|
| RAM | 256 MB | 4 GB or more for a small team |
| Disk | 1 GB | 50 GB or more |
| Java | 21 | 21 (the LTS release with the longest support) |
| OS | Any Linux with systemd, Windows, macOS | Ubuntu 24.04 / Rocky 9 |
# 1. Install Java 21 first
sudo apt update
sudo apt install -y fontconfig openjdk-21-jre
java -version
# 2. Add the signing key
sudo mkdir -p -m 755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2026.key
# 3. Add the LTS repository
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
# 4. Install Jenkins
sudo apt update
sudo apt install -y jenkins
# 5. Start it and enable it at boot
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkinsTo track the weekly releases instead of the LTS line, use
https://pkg.jenkins.io/debian with https://pkg.jenkins.io/debian/jenkins.io-2026.key.
The signing key is rotated periodically. If the key is outdated, apt update fails
with a NO_PUBKEY error — download the current jenkins.io-YYYY.key from the
repository you are using.
Open http://localhost:8080 and paste the initial admin password:
# Linux package
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
# Docker
docker exec jenkins-controller cat /var/jenkins_home/secrets/initialAdminPasswordJenkins runs as a systemd service. The package sets the defaults in the unit file:
# Inspect the configuration
sudo systemctl cat jenkins
# Change the port, JVM options or JENKINS_HOME
sudo systemctl edit jenkins[Service]
Environment="JENKINS_PORT=8081"
Environment="JENKINS_HOME=/var/lib/jenkins"
Environment="JAVA_OPTS=-Djenkins.install.runSetupWizard=false -Xmx2g"# Apply the changes
sudo systemctl daemon-reload
sudo systemctl restart jenkins
# Follow the logs
sudo journalctl -u jenkins -fConfiguration as Code (JCasC) turns your setup into a version-controlled file instead of clicking through the UI.
# casc.yaml
jenkins:
systemMessage: "Managed by Configuration as Code"
numExecutors: 2
mode: EXCLUSIVE
securityRealm:
local:
allowsSignup: false
users:
- id: "admin"
password: "${JENKINS_ADMIN_PASSWORD}"
authorizationStrategy:
globalMatrix:
permissions:
- "Overall/Administer:admin"
- "Overall/Read:authenticated"
remotingSecurity:
enabled: true
unclassified:
location:
url: "https://jenkins.example.com/"
adminAddress: "devops@example.com"
tool:
git:
installations:
- name: "Default"
home: "git"
node:
builtins:
- remoteLauncher: "hudson.slaves.SSHLauncher"
name: "built-in"
numExecutors: 2
labelString: "built-in"# Apply the configuration
sudo systemctl stop jenkins
sudo JENKINS_HOME=/var/lib/jenkins \
java -jar /usr/share/java/jenkins.war \
--configuration-as-code=/etc/jenkins/casc.yamlThe Configuration as Code plugin lets you apply a file from the running instance
(Manage Jenkins → Configuration as Code → View Configuration) and to reload it without
a restart. Keep the YAML in Git and let the plugin apply it on boot with
CASC_JENKINS_CONFIG.
Jenkins runs jobs on agents. The controller itself has two executors by default; the recommended setup is to set the controller's executors to 0 and run every job on dedicated agents.
# In the Configuration as Code file — the controller only coordinates
jenkins:
numExecutors: 0Agents are matched to jobs by labels — for example linux, docker, aarch64 or
production.
# 1. Create the key pair (on the controller or your workstation)
ssh-keygen -f ~/.ssh/jenkins_agent_key
# 2. On the agent host, create the user and install the public key
sudo useradd -m -s /bin/bash jenkins
sudo mkdir -p /home/jenkins/.ssh
cat jenkins_agent_key.pub | sudo tee /home/jenkins/.ssh/authorized_keys
sudo chown -R jenkins:jenkins /home/jenkins/.ssh
sudo chmod 700 /home/jenkins/.ssh
sudo chmod 600 /home/jenkins/.ssh/authorized_keysIn Jenkins: Manage Jenkins → Credentials → Add Credentials with the kind SSH username with private key, then create the node under Manage Jenkins → Nodes → New Node → Permanent Agent and select that credential.
# Start an agent container that the controller connects to over SSH
docker run -d --rm --name=agent1 -p 22:22 \
-e "JENKINS_AGENT_SSH_PUBKEY=$(cat ~/.ssh/jenkins_agent_key.pub)" \
jenkins/ssh-agent:alpine-jdk25For agents behind NAT, run the inbound agent container and paste the secret from Manage Jenkins → Nodes → New Node → Inbound agent:
docker run -d --rm --name=agent1 \
-e "JENKINS_URL=http://controller:8080" \
-e "JENKINS_SECRET=<AGENT_SECRET>" \
jenkins/inbound-agent:latestThe Kubernetes plugin creates a pod per build and removes it afterwards:
# Configure a Kubernetes cloud under Manage Jenkins -> Clouds// Jenkinsfile
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: builder
image: maven:3.9-eclipse-temurin-21
restartPolicy: Never
'''
label "k8s-agent"
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B verify'
}
}
}
}Create a Jenkinsfile in your repository:
pipeline {
agent any
options {
timeout(time: 30, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '20'))
disableConcurrentBuilds()
}
environment {
NODE_ENV = 'test'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Install dependencies') {
steps {
sh 'npm ci'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
post {
always {
echo 'Build finished'
}
failure {
echo 'Build failed'
}
}
}Create the job with Pipeline → Pipeline script from SCM, point it at your repository
and the Jenkinsfile.
| Plugin | What it does |
|---|---|
| Configuration as Code | Manage the controller from a YAML file in Git |
| Pipeline | Declarative and scripted pipelines (built in) |
| Credentials | Store tokens, passwords and SSH keys |
| Kubernetes | Dynamic agents on a Kubernetes cluster |
| GitHub Branch Source | Trigger pipelines from pull requests |
| Warnings Next Generation | Collect compiler and linter warnings |
| SonarQube | Run code quality analysis in the pipeline |
| Prometheus | Export build metrics |
# 1. Back up JENKINS_HOME before every upgrade
sudo systemctl stop jenkins
sudo tar -czf /var/backups/jenkins-$(date +%F).tar.gz -C /var/lib/jenkins .
sudo systemctl start jenkins
# 2. Upgrade the package
sudo apt update && sudo apt install -y --only-upgrade jenkins
# 3. Restart and watch the log
sudo systemctl restart jenkins
sudo journalctl -u jenkins -fEach LTS release has an upgrade guide listing the plugins that need to be updated and the configuration changes that come with it. Read it before upgrading — plugin compatibility is the most common cause of a broken upgrade.
Manage Jenkins → Security).Jenkinsfile or a shell
command.JENKINS_HOME on a schedule and test the restore.Configure GitLab CI/CD pipelines with GitLab 19, install and register GitLab Runner 19.5 with the new authentication tokens, and build secure multi-stage pipelines.
Install and configure Terraform, Ansible, HashiCorp Vault, Consul, Vagrant and Packer with reproducible infrastructure examples, secret management patterns and safe rollout strategies.