Jenkins guide
What Jenkins does in production
Jenkins is an automation server for continuous integration and continuous delivery. Developers push code; Jenkins pulls (or receives webhooks), runs compile/test/deploy steps, and reports pass/fail. It integrates with Git, Docker, Kubernetes, and notification tools — the hub of many delivery pipelines.
CI vs CD
- CI (Continuous Integration) — merge often; each change triggers build + tests
- CD (Continuous Delivery/Deployment) — automated promotion to staging/production after gates pass
Jenkins handles both: a pipeline stage runs unit tests (CI), later stages push images to Harbor or deploy to Kubernetes (CD).
Controller and agents
The controller (formerly master) schedules work, serves the UI, stores configuration, and coordinates pipelines. Agents (formerly slaves/executors) run build steps — on the same machine (built-in executor) or remote VMs, Docker containers, or Kubernetes pods. Heavy builds should run on agents, not overload the controller.
Job types
- Freestyle job — UI-configured steps; legacy but still common
- Pipeline job —
Jenkinsfilein Git (Declarative or Scripted syntax) - Multibranch pipeline — one pipeline per branch/PR automatically
Modern teams prefer Pipeline as Code — the
Jenkinsfile lives in the repo and is reviewed like application code.
Declarative pipeline sketch
pipeline {
agent any
stages {
stage('Build') {
steps { sh 'make build' }
}
stage('Test') {
steps { sh 'make test' }
}
stage('Deploy') {
when { branch 'main' }
steps { sh './deploy.sh' }
}
}
post {
failure { echo 'Notify team' }
}
}
How a build runs
- Trigger — webhook from Git, poll SCM, manual, or cron
- Queue — job waits for a free executor on an agent
- Checkout — SCM plugin clones the repository into a workspace
- Execute — steps run (shell, Docker, Maven, etc.)
- Archive / publish — artifacts, test reports, images
- Result — SUCCESS, UNSTABLE, FAILURE, or ABORTED
Credentials and secrets
Store Git SSH keys, API tokens, and registry passwords in Jenkins
Credentials — referenced by ID in pipelines
(credentials('my-git-key')). Prefer short-lived tokens and
integration with Vault or cloud secret
managers in mature setups. Never hardcode secrets in Jenkinsfiles.
Plugins
Jenkins is extended via plugins (Git, Pipeline, Docker, Kubernetes, Blue Ocean UI, etc.). Pin plugin versions; test upgrades on a staging controller — incompatible plugins are a top cause of post-upgrade breakage.
Web UI and logs
Default URL: http://host:8080 (or behind reverse proxy with TLS).
Each build has a Console Output — the first place to read when
a stage fails. Blue Ocean or Pipeline Stage View shows parallel stages graphically.
Key paths and service
- Home —
JENKINS_HOME(often/var/lib/jenkins) - Jobs config —
$JENKINS_HOME/jobs/ - Plugins —
$JENKINS_HOME/plugins/ - Logs —
$JENKINS_HOME/logs/or systemd journal - Service —
jenkins(package install) or container
Learning resources
- Jenkins documentation — jenkins.io/doc
- Pipeline syntax — Declarative pipeline
- Installing Jenkins — jenkins.io — installing
- Blue Ocean — Pipeline UI
Practice scenarios
Hands-on Jenkins scenarios on live Linux VMs: jenkins