From devops-skills
Generates declarative, scripted Jenkinsfiles and shared libraries for CI/CD pipelines with Docker/K8s agents, parallel stages, approvals, and security scans.
npx claudepluginhub akin-ozer/cc-devops-skills --plugin devops-skillsThis skill uses the workspace's default tool permissions.
Generate production-ready Jenkinsfiles following best practices. All generated files are validated using devops-skills:jenkinsfile-validator skill.
assets/templates/declarative/basic.Jenkinsfileassets/templates/scripted/basic.Jenkinsfileexamples/declarative-ci-basic.Jenkinsfileexamples/declarative-docker.Jenkinsfileexamples/declarative-kubernetes.Jenkinsfileexamples/declarative-matrix.Jenkinsfileexamples/declarative-parallel.Jenkinsfileexamples/declarative-security-scan.Jenkinsfileexamples/declarative-shared-library.Jenkinsfileexamples/scripted-basic.Jenkinsfileexamples/scripted-conditional.Jenkinsfileexamples/scripted-docker.Jenkinsfilereferences/best_practices.mdreferences/common_plugins.mdscripts/generate_declarative.pyscripts/generate_scripted.pyscripts/generate_shared_library.pyscripts/lib/__init__.pyscripts/lib/common_patterns.pyscripts/lib/syntax_helpers.pySearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Generate production-ready Jenkinsfiles following best practices. All generated files are validated using devops-skills:jenkinsfile-validator skill.
vars/, src/, resources/).| 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 |
// 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 |
Process:
assets/templates/declarative/basic.Jenkinsfile to understand the standard structurereferences/best_practices.md for performance, security, and reliability patternsreferences/common_plugins.md for plugin-specific syntaxfailFast true or parallelsAlwaysFailFast() for parallel blocksfingerprint: true when using archiveArtifactsWhen: Complex conditional logic, dynamic generation, full Groovy control Process:
assets/templates/scripted/basic.Jenkinsfile for node/stage patternsUse parallel {} block or matrix {} with axes {} for multi-dimensional builds.
parallelsAlwaysFailFast() or stage-level failFast true).Add SonarQube, OWASP Dependency-Check, Trivy stages with fail thresholds.
python3 scripts/generate_shared_library.py --name my-library --package org.example
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 {
VERSION = '1.0.0'
AWS_KEY = credentials('aws-key-id') // Creates _USR and _PSW vars
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
timestamps()
parallelsAlwaysFailFast()
durabilityHint('PERFORMANCE_OPTIMIZED') // 2-6x faster for simple pipelines
}
parameters {
string(name: 'VERSION', defaultValue: '1.0.0')
choice(name: 'ENV', choices: ['dev', 'staging', 'prod'])
booleanParam(name: 'SKIP_TESTS', defaultValue: false)
}
| 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.
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 {
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.
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}" } } }
}
}
stage('Deploy') {
input { message 'Deploy?'; ok 'Deploy'; submitter 'admin,ops' }
steps { sh './deploy.sh' }
}
IMPORTANT: Place input outside steps to avoid holding agents.
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
def parseJson(String json) {
new groovy.json.JsonSlurper().parseText(json)
}
Rules: No pipeline steps (sh, echo) inside @NonCPS. Use for JsonSlurper, iterators, regex Matchers.
agent { docker { image 'maven:3.9.11'; args '-v $HOME/.m2:/root/.m2'; reuseNode true } }
def img = docker.build("myapp:${BUILD_NUMBER}")
docker.withRegistry('https://registry.example.com', 'creds') { img.push(); img.push('latest') }
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' }
@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'
CRITICAL: ALWAYS validate using devops-skills:jenkinsfile-validator skill:
devops-skills:jenkinsfile-validator skillfailFast true for parallel blocks → apply by defaultValidation 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
When to use scripts vs manual generation:
generate_declarative.py--output--stages, --agent, --build-tool, --build-cmd, --test-cmd, --deploy-*, --notification-*, --archive-artifacts, --k8s-yaml--k8s-yaml accepts either inline YAML content or a path to an existing .yaml/.yml file.[a-z0-9_-]) and shell commands are emitted as escaped Groovy literals.generate_scripted.py--outputgenerate_shared_library.py--name--package, --outputdeployment/<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
--k8s-yaml works with both inline YAML and existing file paths.Always consult Context7 or WebSearch for:
references/common_plugins.mdMay skip external lookup when:
references/common_plugins.mdsh, 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):
mcp__context7__resolve-library-id with /jenkinsci/<plugin-name>-pluginJenkins [plugin-name] plugin documentation 2025references/best_practices.md - Performance, security, reliability patternsreferences/common_plugins.md - Git, Docker, K8s, credentials, notificationsassets/templates/ - Declarative and scripted templatesdevops-skills:jenkinsfile-validator skill - Syntax and best practices validationAlways prefer Declarative unless scripted flexibility is required.