Tool cheatsheet
Jenkins Cheatsheet
Declarative Jenkinsfile syntax for stages, agents, credentials, parameters, parallel steps and notifications, plus running Jenkins.
Running Jenkins
- Start Jenkins in Docker — Run the long-term-support image with a volume for its data. Open http://localhost:8080.
- Find the initial admin password — Read the unlock password from the container's logs or secrets file.
- Trigger a build from the command line — Use jenkins-cli.jar, downloaded from your Jenkins server, with a user and API token.
- Install plugins in an image — Pre-install plugins when building a Jenkins image.
Declarative pipeline basics
- A minimal Jenkinsfile — Put a Jenkinsfile in the root of your repository.
- Run in a Docker container — Run the pipeline inside a container image, so builds have the tools they need.
- Set environment variables — Define variables for the whole pipeline or one stage.
- Set pipeline options — Add a timeout, keep fewer builds and stop on the first failure.
- Ask for parameters — Add build parameters, which appear as a form when you run the job.
- Run on a schedule — Trigger builds by cron or by polling the repository. H spreads the load.
- Run a stage conditionally — Skip a stage unless a condition holds.
Steps and credentials
- Use credentials safely — Bind a stored secret to a variable for a block. Jenkins masks the value in the log.
- Bind credentials in environment — Expose a username and password credential as environment variables.
- Save build artifacts — Keep files from the workspace with the build, with a fingerprint.
- Publish test results — Parse JUnit XML reports so test results show in Jenkins.
- Pass files between stages or agents — Save files in one stage and restore them in another, even on a different agent.
- Wait for approval — Pause the pipeline until someone approves.
- Retry and time-limit a step — Retry a flaky step and give up if it takes too long.
Parallel stages, post actions and libraries
- Run stages in parallel — Run independent stages at the same time.
- Run a matrix of combinations — Run the same stages for each combination of axes.
- React to the result — Run steps after the pipeline depending on the outcome.
- Use a shared library — Load reusable pipeline code defined in another repository.
- Use Groovy in a declarative pipeline — A script block runs arbitrary Groovy for logic that declarative syntax can't express.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.