← Jenkins Engineer: pipelines and operations
03 / 7 · 45 MIN

Pipeline: scope, timing, and evidence

Build stages that allocate resources and retain results explicitly.

Concept and mechanism

A Declarative Pipeline describes where and how stages execute. With top-level agent none, each stage needing a workspace and shell must obtain suitable context. A variable in one stage environment is not automatically shared with the next. Choose the necessary scope for common configuration and keep secrets limited. Timeout placement also changes meaning: stage options with a stage agent include allocation in the limit; with a top-level agent, the global timeout begins after allocation. This distinction helps explain failures before any application command runs. Measure waiting and execution separately rather than increasing every limit. Budget provisioning delay explicitly when capacity is elastic.

Guided application

In a fictional pipeline, tests produce a small report on one agent and another stage needs to analyze it. Stash and unstash transfer files within the run workflow. For several gigabytes or durable releases, assess an artifact repository or compatible Artifact Manager; avoid loading the controller with unnecessary compression and state. Report collection should also be attempted after failure using post always at suitable scope. The block does not create files a test never produced and may need to handle an unavailable workspace. Preserve the original outcome and distinguish test failure from evidence-publication failure. APS then receives useful information even when the normal path is interrupted.

IN PRACTICE

Eight minutes acquiring an agent plus three executing commands exceed a ten-minute stage timeout.

Common pitfalls

Local variable as global; stash as release archive; post as file guarantee; timeout as CPU budget.

Related topics: Architecture, agents, and traceability · Credentials and trust boundaries · Delivery, approval, and retries

Take this idea with you

Define context, scope, and result retention at each step.

Create account

Reference: Declarative syntax and timeout scope · Jenkins LTS 2.568.3; Java 21 or 25 runtime