What is a .jenkinsfile file?
text/x-groovy
A Jenkinsfile defines a Jenkins pipeline as code. Declarative pipelines wrap a `pipeline` block containing agent, environment, options, stages, and post sections, while scripted pipelines are plain Groovy using `node` and `stage` steps; both are Groovy source, so the declarative form is validated against a schema before execution. It normally lives at the repository root with no file extension.
How to use a .jenkinsfile file
Use an example Jenkinsfile to test pipeline linters, Groovy parsers, and CI migration tooling, checking stage and parallel-branch extraction, environment-variable scoping, and that declarative-schema violations are reported with the offending block.
Download example .jenkinsfile files
- Jenkinsfile, Declarative PipelineA declarative Jenkinsfile with a docker agent, options, environment and parameters blocks, a parallel test stage gated by a when expression, and post conditions. The dialect most Jenkins linters target.
- Jenkinsfile, Scripted PipelineThe scripted Jenkinsfile dialect: an imperative node block with Groovy variables, a for loop that builds a parallel branch map at runtime, and try/catch error collection. Structurally unlike the declarative form, and a common parser gap.
- Jenkinsfile Matrix with ExcludesA declarative Jenkins matrix over two axes with a nested excludes block: six platform/arch combinations minus the windows arm64 pair leaves five cells, documented in the specs so an expansion can be scored exactly.
- Jenkinsfile with Shared LibraryA Jenkinsfile importing a pinned shared library and calling three custom steps that no static parser can resolve locally. For testing how tooling reports unknown steps and whether it records the library dependency and its version pin.
- Jenkinsfile, Intentionally InvalidAn intentionally invalid Jenkinsfile: an unclosed stage block so braces never balance, a steps block outside any stage, and a bare identifier where the agent directive needs any, none, or a block. For testing parser error recovery and reporting.