Skip to content
Novus Examples
jenkinsfile898 B

Jenkinsfile with Shared Library

A 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.

Preview — first 41 linesjenkinsfile
@Library('example-shared-library@v2.3.0') _

pipeline {
    agent any

    environment {
        SERVICE = 'orders-api'
    }

    stages {
        stage('Prepare') {
            steps {
                script {
                    exampleUtils.printBanner(env.SERVICE)
                }
            }
        }

        stage('Build') {
            steps {
                exampleBuild(
                    service: env.SERVICE,
                    registry: 'registry.example.invalid',
                    push: false
                )
            }
        }

        stage('Quality gate') {
            steps {
                script {
                    def report = exampleQuality.evaluate(threshold: 80)
                    if (!report.passed) {
                        error("quality gate failed at ${report.score}")
                    }
                }
            }
        }
    }
}

Specifications

System
Jenkins
Syntax
declarative
Library Annotation
@Library
Library Ref
example-shared-library@v2.3.0
Custom Steps
3

Testing contract

Expected to pass
Scenario
Parse a Jenkinsfile whose steps come from an external shared library
Expected result
The pinned library reference example-shared-library@v2.3.0 is recorded and the three unresolved custom steps are reported as external rather than as syntax errors

What is a .jenkinsfile file?

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 this 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.

How to use this file for testing

“Jenkinsfile with Shared Library” is a deterministic Novus Examples fixture for Config testing, Config parsing, Editor testing. TOML, INI, YAML, .env, and dotfile configuration samples with nested sections and typed values — for testing config parsers, loaders, and environment tooling.

Documented properties for this file: JENKINSFILE · 898 bytes. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Pipeline and infrastructure fixtures are inert configuration: steps reference fictional images and scripts, and nothing here executes. Run your linter, schema validator, migrator, or policy engine against them, and expect the deprecated-syntax and intentionally invalid variants to be rejected.

Point your config loader at the file and assert it reads the documented sections and typed values, including any deliberately-tricky nesting or comments.

Generated by generation/pipelines.py. Free for any use, no attribution required — license.