Writing a Declarative Jenkins Pipeline
August 10, 2026 · DevTools
A declarative Jenkins pipeline is a structured block that lives in a Jenkinsfile you commit to your repo. It starts with pipeline {, declares an agent (where it runs — any, or a Docker image), an optional environment block for variables, a stages block holding the work, and an optional post block for cleanup.
Each stage has a name and a steps block; shell commands run inside sh '...'. The stages run in order, and post.always or post.failure let you publish results or notify a team regardless of outcome. Because the pipeline is code, you version it alongside the app and review changes like any other commit. The keywords are fixed and validated, so once the block is well-formed, Jenkins reliably reproduces the same build every time.