Comprehensive toolkit for validating, linting, testing, and automating Jenkinsfile pipelines (both Declarative and Scripted). Use this skill when working with Jenkins pipeline files, validating pipeline syntax, checking best practices, debugging pipeline issues, or working with custom plugins.
82%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Comprehensive toolkit for validating, linting, and testing Jenkinsfile pipelines (both Declarative and Scripted). This skill applies when working with Jenkins pipeline files, validating pipeline syntax, checking best practices, debugging pipeline issues, or working with custom plugins that require documentation lookup.
Use this skill when you need to:
Do not use this skill for:
jenkinsfile-generator instead.# Run from the skill directory
bash scripts/validate_jenkinsfile.sh assets/examples/bad-declarative-pipeline.Jenkinsfile
bash scripts/validate_jenkinsfile.sh --strict assets/examples/declarative-docker.Jenkinsfile# Check a shared library step
bash scripts/validate_shared_library.sh assets/examples/shared-library/vars/buildApp.groovy// Declarative skeleton the validator expects
pipeline {
agent any
stages {
stage('Build') { steps { sh 'make' } }
}
}Declarative: Required sections, directive placement, parallel execution, credential management, combined shell commands.
Scripted: Groovy syntax, node blocks, try-catch-finally, NonCPS annotation usage, variable scoping.
Both types: Hardcoded credential detection, controller-heavy operations (JsonSlurper, HttpRequest), variable declarations, plugin-specific step validation.
Shared Library: vars/*.groovy: call() method, NonCPS annotation correctness, CPS compatibility, camelCase naming, documentation comments. src/**/*.groovy: package declaration, class-filename match, Serializable implementation, wildcard import warnings, static method CPS compatibility.
See references/validation_rules.md for detailed rules, error reporting format, and examples.
Auto-detected: Declarative (pipeline {), Scripted (node block or Groovy outside pipeline block). Clarification is requested only if ambiguous.
# Run complete validation (syntax + security + best practices)
bash scripts/validate_jenkinsfile.sh JenkinsfileAuto-detects pipeline type, validates syntax, scans for hardcoded credentials, checks best practices, and produces a unified summary.
# Full validation (default)
bash scripts/validate_jenkinsfile.sh Jenkinsfile
# Syntax validation only (fastest)
bash scripts/validate_jenkinsfile.sh --syntax-only Jenkinsfile
# Security audit only
bash scripts/validate_jenkinsfile.sh --security-only Jenkinsfile
# Best practices check only
bash scripts/validate_jenkinsfile.sh --best-practices Jenkinsfile
# Skip security checks
bash scripts/validate_jenkinsfile.sh --no-security Jenkinsfile
# Skip best practices
bash scripts/validate_jenkinsfile.sh --no-best-practices Jenkinsfile
# Strict mode (fail on warnings)
bash scripts/validate_jenkinsfile.sh --strict JenkinsfileThe validation system uses a modular script architecture:
scripts/
├── validate_jenkinsfile.sh # Main orchestrator (USE THIS)
│ ├── Auto-detects pipeline type
│ ├── Runs syntax validation
│ ├── Runs security scan
│ ├── Runs best practices check
│ └── Produces unified summary
│
├── validate_declarative.sh # Declarative syntax validator
├── validate_scripted.sh # Scripted syntax validator
├── common_validation.sh # Shared functions + security scan
├── best_practices.sh # 15-point best practices scorer
└── validate_shared_library.sh # Shared library validatorValidate Jenkins Shared Library files using validate_shared_library.sh:
# Validate a single vars file
bash scripts/validate_shared_library.sh vars/myStep.groovy
# Validate entire shared library directory
bash scripts/validate_shared_library.sh /path/to/shared-libraryImportant: Plugin documentation lookup is the assistant's responsibility (not automated in scripts). After running validation, identify unknown plugins and look them up.
Look up documentation when you encounter:
references/common_plugins.md (e.g., customDeploy, sendToDatadog, grafanaNotify)nexusArtifactUploader, sonarQubeScanner)See references/common_plugins.md for documentation on commonly used plugins.
When a user provides a Jenkinsfile for validation:
Run validation using the main script:
bash scripts/validate_jenkinsfile.sh <path-to-jenkinsfile>Optionally read the Jenkinsfile using the Read tool if you need to:
Look up unknown plugins after validation:
references/common_plugins.md firstmcp__context7__resolve-library-id with query "jenkinsci <plugin-name>"Report results with line numbers, severity, and actionable suggestions
Provide inline fix suggestions when errors are found (include corrected code snippets directly in the response)
WHY: Pipeline files that reference shared library steps pass basic validation but fail at runtime when the library step has changed signature.
BAD: Validate Jenkinsfile in isolation when it calls @Library('my-lib') import com.example.Build.
GOOD: Note all @Library calls and cross-reference the library version being loaded.
WHY: The Jenkins Declarative Linter catches structural errors that generic YAML/Groovy checks miss, such as missing steps blocks or invalid directive placement.
BAD: Rely only on Groovy syntax checking for Declarative pipelines.
GOOD: Submit the Jenkinsfile to http://<jenkins>/pipeline-model-converter/validate or use the CLI linter.
WHY: Linters cannot execute the pipeline; validate that sh steps, credentials references, and environment variables exist in the target Jenkins environment.
BAD: Merge pipeline changes based only on linter results.
GOOD: Run the pipeline against a staging branch with a dry-run or canary job before merging to main.
retry(n) in production pipelines without understanding why it was addedWHY: Retry masks flaky steps and increases build time; investigate the root cause instead.
BAD: Add retry(3) to a flaky test stage and close the ticket.
GOOD: Investigate why the step is flaky, fix the root cause, and remove the retry.
WHY: The two syntaxes have different required structure. Validating against the wrong rule set produces false errors and misses real ones.
BAD: Treat a node { ... } file as missing the pipeline { } block and report it as broken.
GOOD: Detect the pipeline type first (pipeline { is Declarative; a node block is Scripted) and apply the matching validator.
WHY: Steps not covered by references/common_plugins.md have plugin-specific parameters. Guessing leads to wrong fix suggestions.
BAD: Declare sonarQubeScanner or customDeploy usage correct or incorrect from memory.
GOOD: Check references/common_plugins.md first, then consult the plugin documentation at https://plugins.jenkins.io/ and report required and optional parameters.
WHY: The security scan flags credentials embedded in the Jenkinsfile. They end up in source control and build logs.
BAD: Treat a hardcoded credential warning as noise and proceed.
GOOD: Replace the literal with a Jenkins credential binding such as withCredentials([...]) and re-run bash scripts/validate_jenkinsfile.sh Jenkinsfile.
WHY: The workflow requires results reported with line numbers, severity and actionable suggestions, plus inline corrected snippets for errors.
BAD: Reply "the Jenkinsfile has problems with its post section".
GOOD: Report the line, the severity, and a corrected code snippet.
WHY: The validator checks for controller-heavy operations such as JsonSlurper and HttpRequest, which run on the Jenkins controller and degrade it.
BAD: Let new JsonSlurper().parseText(...) outside a @NonCPS method pass unmentioned.
GOOD: Flag it and suggest moving the work to an agent step or a correctly annotated @NonCPS method.
Internal:
External:
pantheon-org/tekhne
c8416e9
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.