This is a complete, hands-on Jenkins cheat sheet: install, configure, operate, automate and secure it - with copy-paste commands grouped by task. Bookmark it for day-to-day work, incidents and interviews alike.
Jenkins is a self-hosted automation server that runs build, test and deploy pipelines. Modern Jenkins defines those pipelines as code in a Jenkinsfile checked into the repo.
Why you reach for it
- Runs anywhere you can host it - full control over agents and network
- Enormous plugin ecosystem for almost any tool or cloud
- Pipelines-as-code keep CI logic versioned next to the app
Installation
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 \
-v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPasswordConfiguration reference
A declarative Jenkinsfile with stages and a post block.
pipeline {
agent any
options { timeout(time: 20, unit: 'MINUTES') }
stages {
stage('Build') { steps { sh 'make build' } }
stage('Test') { steps { sh 'make test' } }
stage('Deploy') {
when { branch 'main' }
steps { sh 'make deploy' }
}
}
post {
failure { echo 'Build failed - notifying team' }
always { junit 'reports/**/*.xml' }
}
}Core commands you use daily
# Trigger and follow a build via the CLI
java -jar jenkins-cli.jar -s http://localhost:8080 build myjob -f -vCLI operations
java -jar jenkins-cli.jar -s $URL build myjob -f -v
java -jar jenkins-cli.jar -s $URL list-jobs
java -jar jenkins-cli.jar -s $URL reload-configurationDeclarative pipeline skeleton
pipeline {
agent { label 'docker' }
stages {
stage('build') { steps { sh 'make build' } }
}
post { always { junit 'reports/**/*.xml' } }
}Use it in CI/CD
Reusable logic belongs in a shared library, called from the Jenkinsfile.
@Library('acme-shared') _
standardPipeline(language: 'node', deploy: true)Best-practice checklist
- Use declarative pipelines and shared libraries to avoid copy-paste
- Run builds on ephemeral agents (Docker/Kubernetes) for clean, scalable CI
- Manage configuration as code with JCasC so the controller is reproducible
Common pitfalls to avoid
- Building on the controller instead of ephemeral agents
- Storing credentials in freeform text instead of the Credentials store
- Snowflake controllers configured by hand and impossible to rebuild
Security quick wins
- Store secrets in the Credentials plugin and inject with withCredentials
- Lock down the script security sandbox and keep plugins patched
Works well with
- GitHub Actions - CI/CD built into GitHub - event-driven workflows defined in YAML, with a huge marketplace of actions.
- GitLab CI/CD - Pipelines-as-code baked into GitLab, with built-in registry, environments and security scanning.
- Argo Workflows - Kubernetes-native workflow engine for CI, batch and ML pipelines defined as DAGs.
A cheat sheet is muscle memory on paper - keep it close until the commands live in your fingers.
Want senior help putting Jenkins to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.