⚙️ What is Jenkins? Why It Still Dominates
›Born in 2004, still running millions of pipelines in 2026
Jenkins started as Hudson at Sun Microsystems in 2004. At that time there was no standard way to automatically build, test, or deploy software — teams did it manually, inconsistently, slowly. Jenkins automated the entire process. It became the industry standard for CI/CD and never gave up that position.
Today GitHub Actions, GitLab CI, and Azure DevOps have taken significant share for new projects. But Jenkins dominates in enterprises because: it was there first (millions of Jenkinsfiles already written), its plugin ecosystem (1,800+) covers every integration imaginable, and the migration cost from Jenkins to anything else is enormous.
Jenkins vs alternatives — honest assessment
| Jenkins | GitHub Actions | GitLab CI | Azure DevOps | |
|---|---|---|---|---|
| Who manages infra | You (self-hosted) | GitHub | GitLab | Microsoft |
| Pipeline language | Groovy (Declarative or Scripted) | YAML | YAML | YAML |
| Plugin ecosystem | 1,800+ plugins (unmatched) | GitHub Marketplace | Built-in | Azure Marketplace |
| Free minutes | Unlimited (your server) | 2,000/month | 400/month | 1,800/month |
| Best for | Enterprise, complex pipelines, existing investment | GitHub repos, modern teams | GitLab users | Azure/Microsoft shops |
🖥️ Agents — Where Builds Actually Run
›This is the most misunderstood Jenkins concept
The Jenkins master (controller) is the brain: reads Jenkinsfiles, schedules builds, serves the UI, stores history. It should NEVER run builds directly in production — it is a single point of failure. The agents are the workers: separate machines or containers that actually compile your code, run tests, build Docker images.
Every Jenkins performance problem, every "builds are slow" complaint, traces back to agent configuration. Get agents right and Jenkins scales beautifully. Get them wrong and you have a bottleneck.
The four agent types
| Type | How it works | Best for | Main risk |
|---|---|---|---|
| Master node | Runs on the Jenkins master itself | Testing/demos only | Security risk, resource contention |
| Permanent SSH | Jenkins SSHes into a dedicated VM | Simple setups, always-on needs | Idle cost, environment drift |
| Docker | Fresh container per build | Reproducible builds, clean environment | Docker daemon needed on agent |
| Kubernetes pod | K8s pod per build, auto-destroyed | Cloud-native, auto-scale, zero idle | 10-30 second pod startup overhead |
🔧 Declarative Pipeline — Production Complete
›The Jenkinsfile is your pipeline as code
Your Jenkinsfile lives in the root of your Git repository, versioned alongside your application code. This means: pipeline changes go through PR review, you can blame who broke the pipeline, every branch can have its own pipeline variation, and Jenkins automatically discovers it.
Use Declarative pipeline — it has a strict, validated structure that catches errors before running. Scripted pipeline (pure Groovy) is only needed for complex dynamic logic that Declarative cannot handle. 95% of real-world pipelines should be Declarative.
🔒 Credentials — Zero Secrets in Jenkinsfile
›The absolute rule: no secrets in code
A Jenkinsfile is in Git. Secrets in Git are in Git history forever — even after deletion. Every team member with repo access can see them. Jenkins Credentials store uses AES-128 encryption. Credentials are injected at runtime and automatically masked in all log output as ****.
For production-grade security: integrate with HashiCorp Vault. Jenkins fetches secrets from Vault at pipeline runtime. When a secret rotates in Vault, all pipelines automatically get the new value on next run — zero manual credential updates in Jenkins.
🌿 Multibranch Pipeline
›One Jenkinsfile, automatic pipeline per branch
Multibranch Pipeline discovers all branches in your Git repository and creates a pipeline for each automatically. Feature branches get dev deployment. Main branch triggers staging. Main branch + approval triggers production. When a branch is deleted in Git, its pipeline disappears automatically. Zero manual pipeline management.
Combined with when blocks in your Jenkinsfile: one file, one Jenkinsfile, handles all branches with the appropriate deployment target for each.
🔍 Troubleshooting — Every Real Issue
›☸️ Kubernetes Agents — Dynamic Builds at Scale
›Why Kubernetes agents over static agents
Traditional Jenkins: permanent agents sit idle between builds, wasting resources. With Kubernetes agents: each build spins up a fresh pod, runs the build, terminates. Zero idle cost. Each build gets a clean environment. Scale to hundreds of parallel builds automatically.
How it works
↓ triggers build
Kubernetes Plugin creates Agent Pod (temporary)
↓ agent connects to controller via JNLP
Build runs inside agent pod containers
↓ build completes
Agent pod terminated automatically
Jenkinsfile with Kubernetes agent
pipeline {
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven:3.9-eclipse-temurin-17
command: [cat]
tty: true
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
cpu: "1"
memory: "1Gi"
- name: docker
image: docker:24-dind
securityContext:
privileged: true
"""
}
}
stages {
stage('Build') {
steps {
container('maven') {
sh 'mvn clean package -DskipTests'
}
}
}
stage('Docker Build') {
steps {
container('docker') {
sh 'docker build -t myapp:${BUILD_NUMBER} .'
}
}
}
}
}
Key Kubernetes plugin settings
- Jenkins URL — the URL agents use to connect back to the controller
- Namespace — where agent pods are created (typically
jenkins) - Pod retention — Never (always clean) or On Failure (keep for debugging)
- Service Account — needs permissions to create/delete pods in namespace
🔒 Jenkins High Availability and Backup
›Jenkins HA options
| Approach | How | Best for |
|---|---|---|
| Single controller + backup | Regular JENKINS_HOME backups to S3/blob. Fast restore from backup. | Most teams — simple, cost-effective |
| Jenkins on Kubernetes | Controller as a Deployment with PVC. K8s restarts pod if it crashes. PVC preserves data. | Cloud-native teams |
| CloudBees CI HA | Active-Active setup. Commercial product. | Enterprise with zero downtime requirement |
Backup strategy — what to backup
# JENKINS_HOME critical directories: $JENKINS_HOME/ ├── config.xml # Main Jenkins config ├── credentials.xml # All credentials ├── jobs/ # All job definitions and build history │ └── my-pipeline/ │ └── config.xml # Jenkinsfile path, branch config ├── plugins/ # Installed plugins ├── secrets/ # Encryption keys — CRITICAL │ └── master.key # Without this, credentials cannot be decrypted └── users/ # User accounts # Backup script (run via cron): tar -czf jenkins-backup-$(date +%Y%m%d).tar.gz $JENKINS_HOME/config.xml $JENKINS_HOME/credentials.xml $JENKINS_HOME/jobs/ $JENKINS_HOME/secrets/ # Upload to cloud storage aws s3 cp jenkins-backup-$(date +%Y%m%d).tar.gz s3://my-backups/jenkins/
Jenkins on Kubernetes with persistent storage
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
namespace: jenkins
spec:
replicas: 1 # Jenkins controller is NOT horizontally scalable
template:
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts
volumeMounts:
- name: jenkins-home
mountPath: /var/jenkins_home
volumes:
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins-pvc # PVC survives pod restarts
🔌 Key Plugins Every DevOps Engineer Should Know
›Essential plugins — what they do and why you need them
| Plugin | What it does | When you need it |
|---|---|---|
| Kubernetes | Run builds as Kubernetes pods — dynamic agents | Jenkins on K8s |
| Pipeline | Core Declarative and Scripted Pipeline support | Always |
| Git / GitHub | Checkout code, webhook triggers, GitHub PR integration | Always |
| Docker Pipeline | docker.build(), docker.push(), docker.withRegistry() in Jenkinsfile | Docker CI/CD |
| Credentials Binding | Inject credentials as env vars: withCredentials([usernamePassword()]) | Secret management |
| Blue Ocean | Modern pipeline visualisation UI — see each stage graphically | Team visibility |
| SonarQube Scanner | Run SonarQube analysis from pipeline stage | Code quality gates |
| Slack Notification | slackSend() — notify on success/failure | Team notifications |
| Email Extension | Rich HTML email notifications with build details | Stakeholder notifications |
| Parameterized Trigger | Trigger downstream jobs with parameters | Multi-job pipelines |
| Throttle Concurrent | Limit parallel builds — prevent resource starvation | Resource management |
| Artifact Manager S3/Azure | Store build artifacts in cloud storage | Large artifact management |