
jenkinsfile-generator
Generate/create/scaffold Jenkinsfile — declarative, scripted, shared library, CI/CD pipelines.
- Installs
- 809
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/akin-ozer/cc-devops-skills --skill jenkinsfile-generator- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads jenkinsfile-generator automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Jenkinsfile Generator Skill
Generate production-ready Jenkinsfiles following best practices. All generated files are validated using devops-skills:jenkinsfile-validator skill.
Trigger Phrases
- "Generate a CI pipeline for Maven/Gradle/npm"
- "Create a Jenkins deployment pipeline with approvals"
- "Build a Jenkinsfile with parallel test stages"
- "Create a scripted pipeline with dynamic stage logic"
- "Scaffold a Jenkins shared library"
- "Generate a Jenkinsfile for Docker or Kubernetes agents"
When to Use
- Creating new Jenkinsfiles (declarative or scripted)
- CI/CD pipelines, Docker/Kubernetes deployments
- Parallel execution, matrix builds, parameterized pipelines
- DevSecOps pipelines with security scanning
- Shared library scaffolding
Declarative vs Scripted Decision Tree
- Choose Declarative by default when stage order and behavior are mostly static.
- Choose Scripted when runtime-generated stages, complex loops, or dynamic control flow are required.
- Choose Shared Library scaffolding when request is about reusable pipeline functions (
vars/,src/,resources/). - If unsure, start Declarative and only switch to Scripted if requirements cannot be expressed cleanly.
Template Map
| Template | Path | Use When |
|---|---|---|
| Declarative basic | assets/templates/declarative/basic.Jenkinsfile | Standard CI/CD with predictable stages |
| Declarative parallel example | examples/declarative-parallel.Jenkinsfile | Parallel test/build branches with fail-fast behavior |
| Declarative kubernetes example | examples/declarative-kubernetes.Jenkinsfile | Kubernetes agent execution using pod templates |
| Scripted basic | assets/templates/scripted/basic.Jenkinsfile | Complex conditional logic or generated stages |
| Shared library scaffold | Generated by scripts/generate_shared_library.py | Reusable pipeline functions and organization-wide patterns |
Quick Reference
// Minimal Declarative Pipeline
pipeline {
agent any
stages {
stage('Build') { steps { sh 'make' } }
stage('Test') { steps { sh 'make test' } }
}
}
// Error-tolerant stage
stage('Flaky Tests') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh 'run-flaky-tests.sh'
}
}
}
// Conditional deployment with approval
stage('Deploy') {
when { branch 'main'; beforeAgent true }
input { message 'Deploy to production?' }
steps { sh './deploy.sh' }
}
| Option | Purpose |
|---|---|
timeout(time: 1, unit: 'HOURS') | Prevent hung builds |
buildDiscarder(logRotator(numToKeepStr: '10')) | Manage disk space |
disableConcurrentBuilds() | Prevent race conditions |
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') | Continue on error |
Core Capabilities
1. Declarative Pipelines (RECOMMENDED)
Process:
- Read templates for structure reference:
- Read
assets/templates/declarative/basic.Jenkinsfileto understand the standard structure - Templates show the expected sections: pipeline → agent → environment → options → parameters → stages → post
- For complex requests, adapt the structure rather than copying verbatim
- Read
- Consult reference documentation:
- Read
references/best_practices.mdfor performance, security, and reliability patterns - Read
references/common_plugins.mdfor plugin-specific syntax
- Read
- Generate with required elements:
- Proper stages with descriptive names
- Environment block with credentials binding (never hardcode secrets)
- Options: timeout, buildDiscarder, timestamps, disableConcurrentBuilds
- Post conditions: always (cleanup), success (artifacts), failure (notifications)
- Always add
failFast trueorparallelsAlwaysFailFast()for parallel blocks - Always include
fingerprint: truewhen usingarchiveArtifacts
- ALWAYS validate using devops-skills:jenkinsfile-validator skill
2. Scripted Pipelines
When: Complex conditional logic, dynamic generation, full Groovy control Process:
- Read templates for structure reference:
- Read
assets/templates/scripted/basic.Jenkinsfilefor node/stage patterns - Understand try-catch-finally structure for error handling
- Read
- Implement try-catch-finally for error handling
- ALWAYS validate using devops-skills:jenkinsfile-validator skill
3. Parallel/Matrix Pipelines
Use parallel {} block or matrix {} with axes {} for multi-dimensional builds.
- Default behavior is fail-fast for generated parallel pipelines (
parallelsAlwaysFailFast()or stage-levelfailFast true).
4. Security Scanning (DevSecOps)
Add SonarQube, OWASP Dependency-Check, Trivy stages with fail thresholds.
5. Shared Library Scaffolding
python3 scripts/generate_shared_library.py --name my-library --package org.example
Declarative Syntax Reference
Agent Types
agent any // Any available agent
agent { label 'linux && docker' } // Label-based
agent { docker { image 'maven:3.9.11-eclipse-temurin-21' } }
agent { kubernetes { yaml '...' } } // K8s pod template
agent { kubernetes { yamlFile 'pod.yaml' } } // External YAML
Environment & Credentials
environment {
VERSION = '1.0.0'
AWS_KEY = credentials('aws-key-id') // Creates _USR and _PSW vars
}
Options
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
timestamps()
parallelsAlwaysFailFast()
durabilityHint('PERFORMANCE_OPTIMIZED') // 2-6x faster for simple pipelines
}
Parameters
parameters {
string(name: 'VERSION', defaultValue: '1.0.0')
choice(name: 'ENV', choices: ['dev', 'staging', 'prod'])
booleanParam(name: 'SKIP_TESTS', defaultValue: false)
}
When Conditions
| Condition | Example |
|---|---|
branch | branch 'main' or branch pattern: 'release/*', comparator: 'GLOB' |
tag | tag pattern: 'v*', comparator: 'GLOB' |
changeRequest | changeRequest target: 'main' |
changeset | changeset 'src/**/*.java' |
expression | expression { env.DEPLOY == 'true' } |
allOf/anyOf/not | Combine conditions |
Add beforeAgent true to skip agent allocation if condition fails.
Error Handling
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { sh '...' }
warnError('msg') { sh '...' } // Mark UNSTABLE but continue
unstable(message: 'Coverage low') // Explicit UNSTABLE
error('Config missing') // Fail without stack trace
Post Section
post {
always { junit '**/target/*.xml'; cleanWs() }
success { archiveArtifacts artifacts: '**/*.jar', fingerprint: true }
failure { slackSend color: 'danger', message: 'Build failed' }
fixed { echo 'Build fixed!' }
}
Order: always → changed → fixed → regression → failure → success → unstable → cleanup
NOTE: Always use fingerprint: true with archiveArtifacts for build traceability and artifact tracking.
Parallel & Matrix
IMPORTANT: Always ensure parallel blocks fail fast on first failure using one of these approaches:
Option 1: Global (RECOMMENDED) - Use parallelsAlwaysFailFast() in pipeline options:
options {
parallelsAlwaysFailFast() // Applies to ALL parallel blocks in pipeline
}
This is the preferred approach as it covers all parallel blocks automatically.
Option 2: Per-block - Use failFast true on individual parallel stages:
stage('Tests') {
failFast true // Only affects this parallel block
parallel {
stage('Unit') { steps { sh 'npm test:unit' } }
stage('E2E') { steps { sh 'npm test:e2e' } }
}
}
NOTE: When parallelsAlwaysFailFast() is set in options, explicit failFast true on individual parallel blocks is redundant.
stage('Matrix') {
failFast true
matrix {
axes {
axis { name 'PLATFORM'; values 'linux', 'windows' }
axis { name 'BROWSER'; values 'chrome', 'firefox' }
}
excludes { exclude { axis { name 'PLATFORM'; values 'linux' }; axis { name 'BROWSER'; values 'safari' } } }
stages { stage('Test') { steps { echo "Testing ${PLATFORM}/${BROWSER}" } } }
}
}
Input (Manual Approval)
stage('Deploy') {
input { message 'Deploy?'; ok 'Deploy'; submitter 'admin,ops' }
steps { sh './deploy.sh' }
}
IMPORTANT: Place input outside steps to avoid holding agents.
Scripted Syntax Reference
node('agent-label') {
try {
stage('Build') { sh 'make build' }
stage('Test') { sh 'make test' }
} catch (Exception e) {
currentBuild.result = 'FAILURE'
throw e
} finally {
deleteDir()
}
}
// Parallel
parallel(
'Unit': { node { sh 'npm test:unit' } },
'E2E': { node { sh 'npm test:e2e' } }
)
// Environment
withEnv(['VERSION=1.0.0']) { sh 'echo $VERSION' }
withCredentials([string(credentialsId: 'key', variable: 'KEY')]) { sh 'curl -H "Auth: $KEY" ...' }
@NonCPS for Non-Serializable Operations
@NonCPS
def parseJson(String json) {
new groovy.json.JsonSlurper().parseText(json)
}
Rules: No pipeline steps (sh, echo) inside @NonCPS. Use for JsonSlurper, iterators, regex Matchers.
Docker & Kubernetes
Docker Agent
agent { docker { image 'maven:3.9.11'; args '-v $HOME/.m2:/root/.m2'; reuseNode true } }
Build & Push
def img = docker.build("myapp:${BUILD_NUMBER}")
docker.withRegistry('https://registry.example.com', 'creds') { img.push(); img.push('latest') }
Kubernetes Pod
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven:3.9.11-eclipse-temurin-21
command: [sleep, 99d]
'''
}
}
// Use: container('maven') { sh 'mvn package' }
Shared Libraries
@Library('my-shared-library') _
// or dynamically: library 'my-library@1.0.0'
// vars/log.groovy
def info(msg) { echo "INFO: ${msg}" }
// Usage
log.info 'Starting build'
Validation Workflow
CRITICAL: ALWAYS validate using devops-skills:jenkinsfile-validator skill:
- Generate Jenkinsfile
- Invoke
devops-skills:jenkinsfile-validatorskill - Handle validation results by severity:
- ERRORS: MUST fix before presenting to user - these break the pipeline
- WARNINGS: SHOULD fix - these indicate potential issues
- INFO/SUGGESTIONS: Consider applying based on use case:
failFast truefor parallel blocks → apply by default- Build triggers → ask user if they want automated builds
- Other optimizations → apply if they improve the pipeline
- Re-validate after fixes
- Only present validated Jenkinsfiles to user
Validation commands:
# Full validation (syntax + security + best practices)
bash ../jenkinsfile-validator/scripts/validate_jenkinsfile.sh Jenkinsfile
# Syntax only (fastest)
bash ../jenkinsfile-validator/scripts/validate_jenkinsfile.sh --syntax-only Jenkinsfile
Generator Scripts
When to use scripts vs manual generation:
- Use scripts for: Simple, standard pipelines with common patterns (basic CI, straightforward CD)
- Use manual generation for: Complex pipelines with multiple features (parallel tests + security scanning + Docker + K8s deployments), custom logic, or non-standard requirements
Script Arguments: Required vs Optional
generate_declarative.py- Required:
--output - Optional:
--stages,--agent,--build-tool,--build-cmd,--test-cmd,--deploy-*,--notification-*,--archive-artifacts,--k8s-yaml - Notes:
--k8s-yamlaccepts either inline YAML content or a path to an existing.yaml/.ymlfile.- Stage keys are validated (
[a-z0-9_-]) and shell commands are emitted as escaped Groovy literals. generate_scripted.py- Required:
--output - Optional: stage/agent/SCM/notification parameters depending on requested pipeline features.
generate_shared_library.py- Required:
--name - Optional:
--package,--output - Shared library deployment helper now includes explicit rollout target (
deployment/<name>) and notification helper emits valid HTML email bodies.
# Declarative (simple pipelines)
python3 scripts/generate_declarative.py --output Jenkinsfile --stages build,test,deploy --agent docker
# Scripted (simple pipelines)
python3 scripts/generate_scripted.py --output Jenkinsfile --stages build,test --agent label:linux
# Shared Library (always use script for scaffolding)
python3 scripts/generate_shared_library.py --name my-library --package com.example
Done Criteria
- Pipeline style selection (Declarative vs Scripted) is explicit and justified.
- Generated Jenkinsfiles pass smoke validation with executable validator commands.
- Parallel pipelines are fail-fast by default unless user explicitly requests otherwise.
- Custom stage names and shell commands are safely emitted (no unescaped Groovy literals).
--k8s-yamlworks with both inline YAML and existing file paths.- Notification-enabled post blocks still archive artifacts when requested.
Plugin Documentation Lookup
Always consult Context7 or WebSearch for:
- Plugins NOT covered in
references/common_plugins.md - Version-specific documentation requests
- Complex plugin configurations or advanced options
- When user explicitly asks for latest documentation
May skip external lookup when:
- Using basic plugin syntax already documented in
references/common_plugins.md - Simple, well-documented plugin steps (e.g., basic
sh,checkout scm,junit)
Plugins covered in common_plugins.md: Git, Docker, Kubernetes, Credentials, JUnit, Slack, SonarQube, OWASP Dependency-Check, Email, AWS, Azure, HTTP Request, Microsoft Teams, Nexus, Artifactory, GitHub
Lookup methods (in order of preference):
- Context7:
mcp__context7__resolve-library-idwith/jenkinsci/<plugin-name>-plugin - WebSearch:
Jenkins [plugin-name] plugin documentation 2025 - Official: plugins.jenkins.io, jenkins.io/doc/pipeline/steps/
References
references/best_practices.md- Performance, security, reliability patternsreferences/common_plugins.md- Git, Docker, K8s, credentials, notificationsassets/templates/- Declarative and scripted templatesdevops-skills:jenkinsfile-validatorskill - Syntax and best practices validation
Always prefer Declarative unless scripted flexibility is required.
FAQ
What does the jenkinsfile-generator skill do?
Generate/create/scaffold Jenkinsfile — declarative, scripted, shared library, CI/CD pipelines.
How do I install jenkinsfile-generator?
Run npx skills add https://github.com/akin-ozer/cc-devops-skills --skill jenkinsfile-generator in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/jenkinsfile-generator/ (personal) or .claude/skills/jenkinsfile-generator/ (project).
Which AI agents can use jenkinsfile-generator?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is jenkinsfile-generator safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains jenkinsfile-generator?
It is published by akin-ozer in akin-ozer/cc-devops-skills. It has 809 recorded installs.
More from akin-ozer/cc-devops-skills
ansible-validator
akin-ozer/cc-devops-skills
Validate, lint, audit, or debug Ansible playbooks, roles, inventories, FQCN, tasks.
terragrunt-generator
akin-ozer/cc-devops-skills
Generate/create/scaffold Terragrunt HCL files — root.hcl, terragrunt.hcl, child modules, stacks, multi-env layouts.
k8s-debug
akin-ozer/cc-devops-skills
Diagnose and fix Kubernetes pods, CrashLoopBackOff, Pending, DNS, networking, storage, and rollout failures with kubectl.
ansible-generator
akin-ozer/cc-devops-skills
Generate, create, or scaffold Ansible playbooks, roles, tasks, handlers, inventory, vars.
dockerfile-validator
akin-ozer/cc-devops-skills
Validate, lint, audit, or scan a Dockerfile for security and best practices.
dockerfile-generator
akin-ozer/cc-devops-skills
Create, generate, or write Dockerfiles and multi-stage Docker images. Containerize apps.
Popular devops & cloud skills
microsoft-foundry
microsoft/azure-skills
Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent create, managed harness agent create, GitHub Copilot harness agent, create agent, update agent, add tool to agent, invoke agent, agent insights, evaluate agent, batch eval, continuous eval, continuous monitoring, agent CI/CD, optimize prompt, improve prompt, optimize agent instructions, Agent Optimizer scaffold, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure
azure-diagnostics
microsoft/azure-skills
Debug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe triage. WHEN: debug production issues, troubleshoot app service, app service high CPU, app service deployment failure, troubleshoot container apps, container app 503 or target port mismatch, troubleshoot functions, function telemetry missing or stopped after a config/connection-string change, troubleshoot AKS, VM RDP, Linux SSH, VM black screen, can't connect to VM, reset VM password, NSG or firewall blocking, kubectl cannot connect, kube-system/CoreDNS failures, pod pending, crashloop, node not ready, upgrade failures, analyze logs, KQL, insights, image pull failures, cold start issues, health probe failures, resource health, root cause of errors, troubleshoot event hubs, troubleshoot service bus, messaging SDK error, AMQP connection failure, message lock lost, lock renewal during long-running processing, service bus dead letter.
azure-prepare
microsoft/azure-skills
Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.
azure-ai
microsoft/azure-skills
Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.
azure-deploy
microsoft/azure-skills
Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.
azure-validate
microsoft/azure-skills
Pre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure (Bicep or Terraform), RBAC role assignments, managed identity permissions, and prerequisites before deploying. WHEN: validate my app, check deployment readiness, run preflight checks, verify configuration, check if ready to deploy, validate azure.yaml, validate Bicep, test before deploying, troubleshoot deployment errors, validate Azure Functions, validate function app, validate serverless deployment, verify RBAC roles, check role assignments, review managed identity permissions, what-if analysis, validate Container Apps deployment.