Jenkins Cheat Sheet
Core reference for Jenkins pipelines, Jenkinsfile syntax, common CLI operations, and plugin-based job configuration.
2 PagesIntermediateFeb 20, 2026
Declarative Pipeline
Basic structure of a Jenkinsfile using declarative syntax.
groovy
pipeline { agent any environment { APP_ENV = 'production' } stages { stage('Build') { steps { sh 'mvn clean package' } } stage('Test') { steps { sh 'mvn test' } } stage('Deploy') { when { branch 'main' } steps { sh './deploy.sh' } } } post { always { junit 'target/surefire-reports/*.xml' } failure { mail to: 'team@example.com', subject: 'Build failed' } }}
Scripted Pipeline
Groovy-based scripted syntax for advanced control flow.
groovy
node { stage('Checkout') { checkout scm } stage('Build') { try { sh 'make build' } catch (err) { currentBuild.result = 'FAILURE' throw err } } parallel( unit: { sh 'make test-unit' }, integration: { sh 'make test-integration' } )}
Key Directives
Common directives used inside a Jenkinsfile.
- agent- Specifies where the pipeline or stage executes (any, none, label, docker)
- environment- Defines key-value environment variables for the pipeline or a stage
- parameters- Declares build parameters (string, booleanParam, choice) requested at trigger time
- triggers- Defines automatic triggers such as cron or pollSCM
- post- Defines actions run after stage/pipeline completion (always, success, failure, unstable)
- when- Conditionally executes a stage based on branch, expression, or environment
- parallel- Runs multiple stages/steps concurrently
Jenkins CLI
Common jenkins-cli.jar operations.
bash
java -jar jenkins-cli.jar -s http://localhost:8080/ list-jobsjava -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -fjava -jar jenkins-cli.jar -s http://localhost:8080/ console my-jobjava -jar jenkins-cli.jar -s http://localhost:8080/ create-job new-job < config.xmljava -jar jenkins-cli.jar -s http://localhost:8080/ restart
Pro Tip
Use the Jenkinsfile 'agent { docker { image "node:18" } }' per-stage instead of a global agent to keep build environments isolated and reproducible without polluting your Jenkins nodes.
Was this cheat sheet helpful?
Explore Topics
#Jenkins#JenkinsCheatSheet#DevOps#Intermediate#DeclarativePipeline#ScriptedPipeline#KeyDirectives#JenkinsCLI#CommandLine#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance