A stage is a named phase drawn as one box in the graph; a step is one action from a plugin: sh, echo, git, archiveArtifacts and hundreds more, all listed with a snippet generator at /pipeline-syntax on your controller. A stage holds either steps or a nested stages block of sequential sub-stages. The decl-stages job checks BookNest out as in Pipeline Jobs, then runs:
stage('Verify') {
stages {
stage('Seed data') {
steps {
dir('db') { sh 'grep -c \'"title"\' seed.json' }
writeFile file: 'report.txt', text: "Build ${env.BUILD_NUMBER}: seed data OK\n"
}
}
stage('Health route') {
steps {
retry(2) { sh 'grep -n "/health" app.js' }
timeout(time: 30, unit: 'SECONDS') { sh 'node --version || true' }
}
}
}
}Running in /home/jenkins/agent/workspace/decl-stages/db
...
18: app.get('/health', (req, res) => {
...
/home/jenkins/agent/workspace/decl-stages@tmp/durable-8d50708b/script.sh.copy: 1: node: not
founddir changes directory for a block, retry re-runs a failing block, timeout aborts a hanging one, and writeFile made a report that a later stage archived. The last line shows agent-1 has no Node.js 2,131 , so BookNest's tests cannot run there yet; Docker Agents runs them in a Node.js container. Keep stages coarse, five to ten, named for what a reader of the graph cares about: Checkout, Test, Build image.