Token导航 LogoToken导航TokenDH.com
开发操作浏览器github未标认证来源可访问许可证需确认审计异常

jenkinsfile-generator詹金斯文件生成器

Agent Skill

jenkinsfile-generator 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,864

周安装

161

GitHub Stars

197

下载量

1,288
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:jenkinsfile-generator(詹金斯文件生成器)
来源仓库:https://github.com/akin-ozer/cc-devops-skills
仓库路径:skills/jenkinsfile-generator
安装命令:
npx skills add https://github.com/akin-ozer/cc-devops-skills --skill jenkinsfile-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/akin-ozer/cc-devops-skills --skill jenkinsfile-generator

简介

用于生成和管理 Jenkins Pipeline 脚本,提升 CI/CD 流程自动化水平。

  • 适用于构建、测试和部署场景,支持多阶段流水线配置与集成。
  • 通过 GitHub 仓库安装,需确认权限范围及是否触发网络或文件操作。
  • 建议结合项目实际需求核对生成的 Jenkinsfile 逻辑与安全性。
  • jenkinsfile-generator 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

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

  1. Choose Declarative by default when stage order and behavior are mostly static.
  2. Choose Scripted when runtime-generated stages, complex loops, or dynamic control flow are required.
  3. Choose Shared Library scaffolding when request is about reusable pipeline functions (vars/, src/, resources/).
  4. If unsure, start Declarative and only switch to Scripted if requirements cannot be expressed cleanly.

Template Map

TemplatePathUse When
Declarative basicassets/templates/declarative/basic.JenkinsfileStandard CI/CD with predictable stages
Declarative parallel exampleexamples/declarative-parallel.JenkinsfileParallel test/build branches with fail-fast behavior
Declarative kubernetes exampleexamples/declarative-kubernetes.JenkinsfileKubernetes agent execution using pod templates
Scripted basicassets/templates/scripted/basic.JenkinsfileComplex conditional logic or generated stages
Shared library scaffoldGenerated by scripts/generate_shared_library.pyReusable 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' }
}
OptionPurpose
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:

  1. Read templates for structure reference:

- Read assets/templates/declarative/basic.Jenkinsfile to 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

  1. Consult reference documentation:

- Read references/best_practices.md for performance, security, and reliability patterns - Read references/common_plugins.md for plugin-specific syntax

  1. 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 true or parallelsAlwaysFailFast() for parallel blocks - Always include fingerprint: true when using archiveArtifacts

  1. ALWAYS validate using devops-skills:jenkinsfile-validator skill

2. Scripted Pipelines

When: Complex conditional logic, dynamic generation, full Groovy control Process:

  1. Read templates for structure reference:

- Read assets/templates/scripted/basic.Jenkinsfile for node/stage patterns - Understand try-catch-finally structure for error handling

  1. Implement try-catch-finally for error handling
  2. 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-level failFast 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

ConditionExample
branchbranch 'main' or branch pattern: 'release/*', comparator: 'GLOB'
tagtag pattern: 'v*', comparator: 'GLOB'
changeRequestchangeRequest target: 'main'
changesetchangeset 'src/**/*.java'
expressionexpression {env.DEPLOY == 'true'}
allOf/anyOf/notCombine 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:

  1. Generate Jenkinsfile
  2. Invoke devops-skills:jenkinsfile-validator skill
  3. 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 true for parallel blocks → apply by default - Build triggers → ask user if they want automated builds - Other optimizations → apply if they improve the pipeline

  1. Re-validate after fixes
  2. 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-yaml accepts either inline YAML content or a path to an existing .yaml/.yml file.
  • 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-yaml works 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):

  1. Context7: mcp__context7__resolve-library-id with /jenkinsci/<plugin-name>-plugin
  2. WebSearch: Jenkins [plugin-name] plugin documentation 2025
  3. Official: plugins.jenkins.io, jenkins.io/doc/pipeline/steps/

References

  • references/best_practices.md - Performance, security, reliability patterns
  • references/common_plugins.md - Git, Docker, K8s, credentials, notifications
  • assets/templates/ - Declarative and scripted templates
  • devops-skills:jenkinsfile-validator skill - Syntax and best practices validation

Always prefer Declarative unless scripted flexibility is required.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.97%
按下载量换算450

Claude

27.98%
按下载量换算360

Cursor

17.96%
按下载量换算231

Gemini CLI

9.26%
按下载量换算119

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills