Beginner 4 min · June 21, 2026

Jenkins Installation and Setup: Zero-to-Production CI/CD in 30 Minutes

Jenkins installation and setup guide for beginners.

N
Naren Founder & Principal Engineer

20+ years shipping production infrastructure and CI/CD at scale. Lessons pulled from things that broke in production.

Follow
Production
production tested
June 21, 2026
last updated
1,577
articles · all by Naren
 ● Production Incident 🔎 Debug Guide
Quick Answer

Install Java 11 or 17, download the Jenkins WAR or use the official Docker image, start the service, unlock via initial admin password, install suggested plugins, and create your first freestyle job.

✦ Definition~90s read
What is Jenkins Installation and Setup?

Jenkins is an open-source automation server that orchestrates build, test, and deployment pipelines. It runs as a Java web application, scheduling jobs triggered by code commits, timers, or manual actions.

Think of Jenkins as a factory foreman.
Plain-English First

Think of Jenkins as a factory foreman. You give him a checklist (pipeline) of tasks: 'pull code, run tests, package, deploy.' He watches the factory floor (your repo) and executes that checklist every time a new shipment (commit) arrives. If a step fails, he stops the line and yells (sends alerts). Without him, you'd be running around doing each step manually—and missing things at 2 AM.

I've seen a single misconfigured Jenkins job take down an entire production deployment pipeline. Not because the code was bad—because the build server ran out of disk space mid-deploy and left a half-baked artifact in production. That's the kind of pain Jenkins is supposed to prevent, but only if you set it up right. This guide walks you through installation and setup from zero, assuming you've never touched a CI/CD tool. By the end, you'll have a running Jenkins instance with a job that builds, tests, and deploys a sample app—and you'll know the gotchas that separate a reliable pipeline from a ticking time bomb.

Why Jenkins? The Problem It Solves

Before Jenkins, teams built and deployed manually. Someone would SSH into a server, pull the latest code, compile, and restart the service. Every time. At 3 AM. And when they forgot a step—like running database migrations—the site went down. Jenkins automates that checklist. It watches your repository and runs your pipeline on every commit. The alternative is a fragile, human-dependent process that breaks under pressure.

Senior Shortcut:
If your team is smaller than 5 people and you're not deploying more than once a week, consider GitHub Actions or GitLab CI. Jenkins is powerful but has a steep operational cost.

Prerequisites: What You Need Before Installing

Jenkins is a Java application. You need a Java Runtime Environment (JRE) version 11 or 17—OpenJDK is fine. Don't use Java 8; it's end-of-life and Jenkins 2.4xx dropped support. You also need a machine with at least 2GB RAM and 10GB free disk. For production, double that. I've seen Jenkins eat 4GB RAM under load with 10 concurrent builds. Also, ensure port 8080 is open—that's the default web UI port. If you're behind a corporate proxy, grab the proxy URL and credentials now; you'll need them for plugin installation.

PrerequisitesCheck.shDEVOPS
1
2
3
4
5
6
7
8
9
10
11
12
13
// io.thecodeforge — DevOps tutorial

# Check Java version
java -version 2>&1 | grep -i version
# Should output something like: openjdk version "11.0.18" 2023-01-17

# Check available disk
df -h / | tail -1
# Look for at least 10GB available

# Check RAM
free -h | grep Mem
# At least 2GB total
Output
openjdk version "11.0.18" 2023-01-17
/dev/sda1 49G 12G 35G 26% /
Mem: 3.8G 1.2G 2.6G

Installation: Three Ways to Get Jenkins Running

You have three options: native package, Docker, or WAR file. For beginners, I recommend the native package (apt/yum) because it sets up systemd service and default paths. Docker is great for ephemeral environments but adds complexity with volumes and networking. The WAR file is for advanced users who want to run Jenkins embedded in another app server. We'll cover native package on Ubuntu—the most common setup. On Ubuntu 20.04+, run the commands below. On CentOS/RHEL, use yum with the official Jenkins repo.

InstallJenkinsUbuntu.shDEVOPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// io.thecodeforge — DevOps tutorial

# Add Jenkins repository key and source
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

# Update and install
sudo apt-get update
sudo apt-get install -y jenkins

# Start and enable on boot
sudo systemctl start jenkins
sudo systemctl enable jenkins

# Check status
sudo systemctl status jenkins
Output
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-11-20 10:15:30 UTC; 5s ago
Production Trap:

Initial Setup: Unlock and Configure

After installation, Jenkins is locked down. You need the initial admin password, stored in /var/lib/jenkins/secrets/initialAdminPassword. Copy it, then open http://your-server:8080 in a browser. Paste the password. Next, you'll see the 'Customize Jenkins' screen. Choose 'Install suggested plugins'—it installs the most common ones (Git, Pipeline, Blue Ocean). This takes 2-5 minutes depending on internet speed. After plugins install, create your first admin user. Don't skip this; the default admin user is insecure. Set a strong password and store it in a password manager.

GetInitialPassword.shDEVOPS
1
2
3
4
5
// io.thecodeforge — DevOps tutorial

# Display the initial admin password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
# Output example: a1b2c3d4e5f6g7h8i9j0
Output
a1b2c3d4e5f6g7h8i9j0
Senior Shortcut:
If you're automating Jenkins setup, use the Jenkins Configuration as Code (JCasC) plugin. Define everything in a YAML file—no manual clicks. But for your first time, do it manually to understand the components.

Creating Your First Job: The Hello World of CI/CD

Now you have a running Jenkins. Let's create a freestyle job that pulls code from a Git repo and runs a simple build. This is the 'Hello World' of CI/CD. Later you'll graduate to pipelines. Click 'New Item', name it 'MyFirstJob', select 'Freestyle project'. Under 'Source Code Management', choose Git and enter a repo URL (use a public one like https://github.com/jenkins-docs/simple-java-maven-app). Under 'Build', click 'Add build step' > 'Invoke top-level Maven targets' and enter clean package. Save and click 'Build Now'. Watch the console output. If it's green, you've got a working CI pipeline.

JenkinsJobConfig.xmlDEVOPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// io.thecodeforge — DevOps tutorial

<!-- This is the config.xml for a freestyle job. You can create it via UI or copy to jobs/MyFirstJob/config.xml -->
<project>
  <actions/>
  <description>My first Jenkins job</description>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="hudson.plugins.git.GitSCM">
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
        <url>https://github.com/jenkins-docs/simple-java-maven-app</url>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
        <name>*/main</name>
      </hudson.plugins.git.BranchSpec>
    </branches>
  </scm>
  <builders>
    <hudson.tasks.Maven>
      <targets>clean package</targets>
      <usePrivateRepository>false</usePrivateRepository>
    </hudson.tasks.Maven>
  </builders>
  <publishers/>
</project>
Output
Console Output:
Started by user admin
Building in workspace /var/lib/jenkins/workspace/MyFirstJob
Cloning repository https://github.com/jenkins-docs/simple-java-maven-app
[INFO] Scanning for projects...
[INFO] Building simple-java-maven-app 1.0
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ simple-java-maven-app ---
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ simple-java-maven-app ---
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/MyFirstJob/target/classes
[INFO] --- maven-package-plugin:2.5:package (default-package) @ simple-java-maven-app ---
[INFO] Building jar: /var/lib/jenkins/workspace/MyFirstJob/target/simple-java-maven-app-1.0.jar
[INFO] BUILD SUCCESS
Finished: SUCCESS
The Classic Bug:
If the build fails with 'mvn: command not found', you need to install Maven on the Jenkins server or use a Docker agent. Install Maven via sudo apt install maven or add the Maven tool in Manage Jenkins > Global Tool Configuration.

Securing Jenkins: Don't Skip This

Out of the box, Jenkins has no authentication for anonymous users. Anyone on your network can access the UI, see job configurations, and trigger builds. That's a security nightmare. Go to Manage Jenkins > Configure Global Security. Under 'Access Control', select 'Jenkins’ own user database' and check 'Allow users to sign up' (disable after initial setup). Under 'Authorization', choose 'Logged-in users can do anything' for small teams, or 'Matrix-based security' for fine-grained control. Also, enable CSRF protection and set the agent TCP port to random or fixed. I've seen a disgruntled intern delete all jobs because security was off.

Never Do This:
Never expose Jenkins directly to the internet without HTTPS and authentication. Use a reverse proxy (Nginx) with Let's Encrypt SSL. Otherwise, your Jenkins becomes a crypto-mining botnet target.

Pipeline as Code: Moving Beyond Freestyle Jobs

Freestyle jobs are fine for simple tasks, but they don't scale. For real projects, use Jenkins Pipeline—a DSL defined in a Jenkinsfile stored in your repo. This treats your CI/CD as code: versioned, reviewable, testable. A pipeline can have stages (Build, Test, Deploy) with parallel steps and conditional logic. Create a new Pipeline job and point it to your repo's Jenkinsfile. Here's a minimal example that builds and tests a Java app.

JenkinsfileDEVOPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// io.thecodeforge — DevOps tutorial

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                echo 'Building...'
                sh 'mvn clean compile'
            }
        }
        stage('Test') {
            steps {
                echo 'Testing...'
                sh 'mvn test'
            }
        }
        stage('Package') {
            steps {
                echo 'Packaging...'
                sh 'mvn package'
            }
        }
    }
    post {
        success {
            echo 'Pipeline succeeded!'
        }
        failure {
            echo 'Pipeline failed!'
        }
    }
}
Output
Started by user admin
[Pipeline] Start of Pipeline
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Building...
[Pipeline] sh
+ mvn clean compile
[INFO] BUILD SUCCESS
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
Testing...
[Pipeline] sh
+ mvn test
[INFO] BUILD SUCCESS
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Package)
[Pipeline] echo
Packaging...
[Pipeline] sh
+ mvn package
[INFO] BUILD SUCCESS
[Pipeline] }
[Pipeline] // stage
[Pipeline] post
[Pipeline] echo
Pipeline succeeded!
[Pipeline] End of Pipeline
Finished: SUCCESS
Senior Shortcut:
Use the 'Declarative Pipeline' syntax (as above) over Scripted Pipeline. It's easier to read and has better error messages. Save Scripted for complex logic like dynamic parallel branches.

Managing Plugins: The Good, the Bad, the Ugly

Plugins extend Jenkins. There are over 1,800. Most are community-maintained and some are abandoned. The classic mistake: install every plugin that looks useful. This bloats the UI, slows startup, and introduces conflicts. Stick to essentials: Git, Pipeline, Blue Ocean (for a modern UI), Credentials Binding, and Docker Pipeline. Avoid plugins that overlap with core functionality (e.g., 'Build Pipeline Plugin' is obsolete now that Pipeline exists). To install, go to Manage Jenkins > Manage Plugins > Available. Search and install. Restart Jenkins after installation—some plugins require it.

Production Trap:
Plugin updates can break your pipelines. Always test updates on a staging Jenkins instance first. I've seen a Slack notification plugin update change the message format and break downstream parsers.

Setting Up Build Agents: Scaling Beyond One Machine

A single Jenkins master can only run so many builds. For production, you need build agents (formerly slaves) to distribute load. Agents can be permanent VMs, Docker containers, or ephemeral cloud instances. To add a permanent agent: Manage Jenkins > Manage Nodes > New Node. Give it a name, set 'Number of executors' (usually 1-2 per CPU core), and provide the agent's connection details (SSH or JNLP). The agent needs Java installed and a user with SSH access. For Docker agents, use the Docker plugin to spin up containers on demand—perfect for isolated builds.

AgentSetup.shDEVOPS
1
2
3
4
5
6
7
8
9
10
11
// io.thecodeforge — DevOps tutorial

# On the agent machine, install Java and create a jenkins user
sudo apt update
sudo apt install -y openjdk-11-jre
sudo useradd -m -s /bin/bash jenkins
sudo passwd jenkins  # set a strong password

# On the master, add the agent via UI or CLI
# Then on agent, run the agent command from Jenkins UI:
# java -jar agent.jar -jnlpUrl http://master:8080/computer/agent-name/slave-agent.jnlp -secret <secret> -workDir "/home/jenkins"
Output
Agent successfully connected. Executor count: 2. Online.
The Classic Bug:
If agents disconnect frequently, check network latency and firewall rules. JNLP agents use a random TCP port by default—set a fixed port in Manage Jenkins > Configure Global Security > Agents > TCP port for inbound agents.

Backup and Disaster Recovery: Because It Will Fail

Jenkins stores everything in $JENKINS_HOME (default /var/lib/jenkins). That includes jobs, configs, build logs, and credentials. Lose that directory, lose everything. Back it up regularly. Use a cron job to tar the directory and copy it to S3 or another server. For credentials, use the Credentials Binding plugin and store secrets in a vault (like HashiCorp Vault) rather than in Jenkins. Also, snapshot the entire server before major upgrades. I've seen a failed plugin upgrade corrupt the config.xml and require a restore from backup.

BackupScript.shDEVOPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// io.thecodeforge — DevOps tutorial

#!/bin/bash
# Backup Jenkins home directory
BACKUP_DIR="/backup/jenkins"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR

# Stop Jenkins to ensure consistent backup
sudo systemctl stop jenkins

# Create tar archive
tar -czf $BACKUP_DIR/jenkins_backup_$TIMESTAMP.tar.gz -C /var/lib jenkins

# Start Jenkins
sudo systemctl start jenkins

# Optional: upload to S3
# aws s3 cp $BACKUP_DIR/jenkins_backup_$TIMESTAMP.tar.gz s3://my-jenkins-backups/

echo "Backup completed: $BACKUP_DIR/jenkins_backup_$TIMESTAMP.tar.gz"
Output
Backup completed: /backup/jenkins/jenkins_backup_20231120_103000.tar.gz
Never Do This:
Never store plain-text passwords in Jenkins job configs or scripts. Use the Credentials Binding plugin to inject secrets as environment variables. Otherwise, anyone with UI access can see them in console output.
● Production incidentPOST-MORTEMseverity: high

The Disk That Killed the Pipeline

Symptom
Builds started failing randomly with 'No space left on device' errors. Deployments stalled for 4 hours.
Assumption
Assumed a rogue log file was eating disk. Ran du -sh /var/log — nothing unusual.
Root cause
Jenkins stores every build artifact in $JENKINS_HOME/jobs/<job>/builds/. Over 6 months, old builds accumulated 200GB of artifacts. Default retention policy keeps builds forever.
Fix
Set 'Discard Old Builds' in each job: keep max 10 builds, discard artifacts older than 7 days. Also ran jenkins-cli delete-builds <job> 1-1000 to clean up.
Key lesson
  • Always set a build retention policy before the first build runs.
  • Disk is the silent killer of Jenkins.
Production debug guideSystematic recovery paths for the failure modes engineers actually hit.3 entries
Symptom · 01
Jenkins won't start — 'Failed to start Jenkins Continuous Integration Server'
Fix
1. Check logs: sudo journalctl -u jenkins -n 50. 2. Verify Java: java -version. 3. Check disk space: df -h. 4. Fix: Increase disk or reinstall Java.
Symptom · 02
Build fails with 'Error: Connection refused' when pulling from Git
Fix
1. Check network: ping github.com. 2. Check proxy settings in Manage Jenkins > Manage Plugins > Advanced. 3. Fix: Add proxy or use SSH keys instead of HTTPS.
Symptom · 03
Plugins fail to install — 'java.io.IOException: Download failed'
Fix
1. Check internet connectivity. 2. Check proxy settings. 3. Manually download plugin .hpi file and upload via Manage Jenkins > Manage Plugins > Advanced > Upload Plugin.
Feature / AspectNative Package (apt/yum)Docker
Setup complexityLow — one-liner installMedium — requires Docker knowledge
PersistenceBuilt-in systemd serviceMust mount volumes for JENKINS_HOME
Upgrade processapt upgradePull new image, recreate container
Plugin compatibilityFullFull (same WAR)
Resource isolationShares host resourcesContainer-level limits

Key takeaways

1
Jenkins is a Java app
always match Java version to Jenkins LTS requirements. Java 11 or 17 is safe.
2
Security first
enable authentication, use HTTPS, and never run as root. A misconfigured Jenkins is a backdoor into your infrastructure.
3
Disk space is the silent killer
set build retention policies before the first build runs.
4
Pipeline as Code (Jenkinsfile) is non-negotiable for production. Freestyle jobs are for experiments only.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

FAQ · 4 QUESTIONS

Frequently Asked Questions

01
What is the easiest way to install Jenkins on Ubuntu?
02
What's the difference between Jenkins and GitHub Actions?
03
How do I reset the Jenkins admin password?
04
Can Jenkins run Docker containers as build agents?
N
Naren Founder & Principal Engineer

20+ years shipping production infrastructure and CI/CD at scale. Lessons pulled from things that broke in production.

Follow
Verified
production tested
June 21, 2026
last updated
1,577
articles · all by Naren
🔥

That's Jenkins. Mark it forged?

4 min read · try the examples if you haven't

Previous
Introduction to Jenkins
2 / 23 · Jenkins
Next
Jenkins Architecture: Controller and Agent