/devops-skills:jenkinsfile-validatorfrom devops-skills
Validates, lints, and tests Jenkinsfile pipelines (Declarative and Scripted) and Shared Library files. Checks syntax, best practices, security, and performance.
Ships in devops-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
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.
The skill automatically detects the pipeline type:
pipeline { blocknode or contains Groovy code outside pipeline blockFollow this workflow when validating Jenkinsfiles to catch issues early and ensure pipeline quality:
# Run complete validation (syntax + security + best practices)
bash scripts/validate_jenkinsfile.sh Jenkinsfile
This single command:
# 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 Jenkinsfile
┌─────────────────────────────────────────────────────────────┐
│ 1. Type Detection (Automatic) │
│ ├─ Declarative: starts with 'pipeline {' │
│ └─ Scripted: starts with 'node' or Groovy code │
│ ↓ │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 2. Syntax Validation (Required) │
│ ├─ Structure validation │
│ ├─ Required sections │
│ └─ Groovy syntax │
│ ↓ │
│ Reports errors → Continues to next phase │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 3. Security Scan (Required) │
│ ├─ Hardcoded credentials │
│ ├─ API keys / tokens │
│ ├─ Cloud provider credentials │
│ └─ Private keys / certificates │
│ ↓ │
│ Reports issues → Continues to next phase │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 4. Best Practices Check (Recommended) │
│ ├─ Combined shell commands │
│ ├─ Timeout configuration │
│ ├─ Workspace cleanup │
│ ├─ Error handling │
│ └─ Test result publishing │
│ ↓ │
│ Reports suggestions → Complete with summary │
└─────────────────────────────────────────────────────────────┘
**Note:** All validation phases run regardless of errors found in previous phases.
This ensures comprehensive reporting of all issues in a single run.
The 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
│ └── Called automatically for pipeline {} blocks
│
├── validate_scripted.sh # Scripted syntax validator
│ └── Called automatically for node {} blocks
│
├── common_validation.sh # Shared functions + security scan
│ ├── detect_type: Determine pipeline type
│ ├── check_credentials: Security credential scan
│ └── Common utilities
│
├── best_practices.sh # 15-point best practices scorer
│ └── Performance, security, maintainability checks
│
└── validate_shared_library.sh # Shared library validator
└── For vars/*.groovy and src/**/*.groovy files
Key Point: Always use validate_jenkinsfile.sh as the main entry point - it orchestrates all other scripts automatically.
If you need to run validators separately (for debugging or specific checks):
# Detect pipeline type
bash scripts/common_validation.sh detect_type Jenkinsfile
# Run syntax validation only
bash scripts/validate_declarative.sh Jenkinsfile # For declarative
bash scripts/validate_scripted.sh Jenkinsfile # For scripted
# Run security checks only
bash scripts/common_validation.sh check_credentials Jenkinsfile
# Run best practices check only
bash scripts/best_practices.sh Jenkinsfile
Validate 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-library
# Validate just vars directory
bash scripts/validate_shared_library.sh vars/
# Validate just src directory
bash scripts/validate_shared_library.sh src/
The shared library validator checks:
Example output:
=== Validating Global Variable: myStep ===
File: vars/myStep.groovy
=== Validation Results ===
ERRORS (2):
ERROR [Line 15]: @NonCPS method contains pipeline steps (sh, echo, etc.)
ERROR [Line 15]: → Pipeline steps cannot be used in @NonCPS methods
WARNINGS (3):
WARNING [Line 22]: Using 'new File()' - prefer readFile/writeFile for pipeline compatibility
WARNING [Line 1]: No call() method found - file may not be callable as a step
WARNING [Line 1]: Filename 'BadStep' should be camelCase starting with lowercase
=== Summary ===
✗ Validation failed with 2 error(s) and 3 warning(s)
Important: Plugin documentation lookup is Claude's responsibility (not automated in scripts). After running validation, Claude should identify unknown plugins and look them up.
Look up documentation when you encounter:
references/common_plugins.md (e.g., customDeploy, sendToDatadog, grafanaNotify)nexusArtifactUploader, sonarQubeScanner)┌─────────────────────────────────────────────────────────────┐
│ 1. Identify Unknown Plugin Step │
│ - Review Jenkinsfile for unrecognized steps │
│ - Example: customDeploy, nexusPublish, datadogEvent │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 2. Check Local Reference First │
│ - Read: references/common_plugins.md │
│ - Contains: git, docker, kubernetes, credentials, etc. │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 3. Use Context7 MCP (if not in local reference) │
│ - mcp__context7__resolve-library-id │
│ query: "jenkinsci <plugin-name>-plugin" │
│ - mcp__context7__get-library-docs │
│ for usage examples and parameters │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 4. Web Search Fallback (if Context7 has no results) │
│ - WebSearch: "Jenkins <plugin-name> plugin documentation"│
│ - Official source: https://plugins.jenkins.io/ │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 5. Provide Usage Guidance │
│ - Required vs optional parameters │
│ - Best practices for the plugin │
│ - Security considerations │
└─────────────────────────────────────────────────────────────┘
// User's Jenkinsfile contains:
stage('Deploy') {
steps {
nexusArtifactUploader artifacts: [[...]], nexusUrl: 'http://nexus'
datadogEvent title: 'Deployment', text: 'Deployed v1.0'
}
}
Claude's Actions:
nexusArtifactUploader and datadogEvent are not in common_plugins.mdmcp__context7__resolve-library-id with "jenkinsci nexus-artifact-uploader"The skill includes comprehensive reference documentation:
sh step with multiple commands instead of multiple sh stepscredentials() or withCredentials, never hardcode secretsparallel for independent stages${VAR} vs $VAR)Validation results include:
ERROR [Line 5]: Missing required section 'agent'
→ Add 'agent any' or specific agent configuration at top level
WARNING [Line 12]: Multiple consecutive 'sh' steps detected
→ Combine into single sh step with triple-quoted string
→ See: best_practices.md#combine-shell-commands
INFO [Line 23]: Consider using parallel execution for independent stages
→ See: references/declarative_syntax.md#parallel-stages
When a user provides a Jenkinsfile for validation:
Run the main validation script (recommended - handles everything automatically):
bash scripts/validate_jenkinsfile.sh <path-to-jenkinsfile>
This single command auto-detects pipeline type, runs syntax validation, security scan, and best practices check.
Optionally read the Jenkinsfile using the Read tool if you need to:
After validation, scan for unknown plugins (Claude's responsibility):
references/common_plugins.md first for documentationmcp__context7__resolve-library-id with query "jenkinsci "Report results with line numbers, severity, and actionable suggestions
Provide inline fix suggestions when errors are found (do not use AskUserQuestion - include corrected code snippets directly in the response)
User: "Validate my Jenkinsfile"
1. Read the Jenkinsfile
2. Detect type: Declarative (starts with 'pipeline {')
3. Run: bash scripts/validate_declarative.sh Jenkinsfile
4. Run: bash scripts/best_practices.sh Jenkinsfile
5. Report results with suggestions
User: "Check this pipeline with custom plugin steps"
1. Read Jenkinsfile
2. Run validation
3. Detect unknown step (e.g., 'customDeploy')
4. Search context7 for plugin docs
5. If not found, web search "Jenkins custom deploy plugin"
6. Validate plugin usage against found documentation
7. Report results
User: "Check for security issues in my pipeline"
1. Read Jenkinsfile
2. Run: bash scripts/common_validation.sh check_credentials Jenkinsfile
3. Scan for hardcoded secrets, passwords, API keys
4. Check credential management best practices
5. Report security findings with fix suggestions
sh '''
echo "Building..."
mkdir build
./gradlew build
echo "Build complete"
'''
sh 'echo "Building..."'
sh 'mkdir build'
sh './gradlew build'
sh 'echo "Build complete"'
withCredentials([string(credentialsId: 'api-key', variable: 'API_KEY')]) {
sh 'curl -H "Authorization: Bearer $API_KEY" ...'
}
sh 'curl -H "Authorization: Bearer abc123xyz" ...'
When this skill is invoked:
Issue: "Best practices check shows false negatives"
Issue: "Syntax validation passes but pipeline fails on Jenkins"
Issue: "Security scan shows passed but best practices finds credentials"
Issue: "Scripts not executable"
chmod +x scripts/*.shEnable verbose output for troubleshooting:
# Run with bash debug mode
bash -x scripts/validate_jenkinsfile.sh Jenkinsfile
# Check individual validator output
bash scripts/validate_declarative.sh Jenkinsfile
bash scripts/best_practices.sh Jenkinsfile
bash scripts/common_validation.sh check_credentials Jenkinsfile
examples/bad-declarative-pipeline.Jenkinsfile (opens in a new tab)examples/bad-scripted-pipeline.Jenkinsfile (opens in a new tab)examples/declarative-docker.Jenkinsfile (opens in a new tab)examples/declarative-kubernetes.Jenkinsfile (opens in a new tab)examples/declarative-parallel.Jenkinsfile (opens in a new tab)examples/declarative-unknown-plugins.Jenkinsfile (opens in a new tab)examples/scripted-basic.Jenkinsfile (opens in a new tab)examples/scripted-conditional.Jenkinsfile (opens in a new tab)examples/scripted-docker.Jenkinsfile (opens in a new tab)examples/shared-library/src/com/example/BuildConfig.groovy (opens in a new tab)examples/shared-library/vars/BadStep.groovy (opens in a new tab)examples/shared-library/vars/buildApp.groovy (opens in a new tab)references/best_practices.md (opens in a new tab)references/common_plugins.md (opens in a new tab)references/declarative_syntax.md (opens in a new tab)references/scripted_syntax.md (opens in a new tab)scripts/best_practices.sh (opens in a new tab)scripts/common_validation.sh (opens in a new tab)scripts/validate_declarative.sh (opens in a new tab)scripts/validate_jenkinsfile.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
Generated from the plugin's indexed repository (gitjfmd/ansible-skills) — no native marketplace selected
npx claudepluginhub p/gitjfmd-devops-skills-devops-skills-plugin31 skills in this plugin
/ansible-generatorComprehensive toolkit for generating best practice Ansible playbooks, roles, tasks, and inventory files./ansible-validatorComprehensive toolkit for validating, linting, testing, and automating Ansible playbooks, roles, and collections. Use this skill when working with Ansible files (.yml, .yaml playbooks, roles, inventories), validating automation code, debugging playbook execution, performing dry-run testing with check mode, or working with custom modules and collections./azure-pipelines-generatorComprehensive toolkit for generating best practice Azure DevOps Pipelines following current standards and conventions. Use this skill when creating new Azure Pipelines, implementing CI/CD workflows, or building deployment pipelines./azure-pipelines-validatorComprehensive toolkit for validating, linting, and securing Azure DevOps Pipeline configurations./bash-script-generatorComprehensive toolkit for generating best practice bash scripts following current standards and conventions. Use this skill when creating new bash scripts, implementing shell automation, text processing workflows, or building production-ready command-line tools./bash-script-validatorComprehensive toolkit for validating, linting, and optimizing bash and shell scripts. Use this skill when working with shell scripts (.sh, .bash), validating script syntax, checking for best practices, identifying security issues, or debugging shell script problems.