Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计异常

jenkinsjenkins 搜索

Agent Skill

用于辅助云资源、部署、容器、基础设施和运维自动化任务。它适合让 Agent 检查配置、整理部署步骤、分析资源状态、生成排障思路或辅助云服务接入。使用时需要明确目标环境、账号权限、区域和资源组,区分本地测试与生产操作;涉及删除资源、重启服务、修改网络或权限配置时,应先确认影响范围。

总安装

799

周安装

32

GitHub Stars

18

下载量

259
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill jenkins

简介

用于通过 Jenkins 自动化构建、测试与部署软件交付流水线。

  • 适合配置声明式或脚本化 Pipeline、管理插件与共享库复用逻辑。
  • 可集成外部工具链(如 SonarQube、Docker)实现质量门禁与镜像构建。
  • 需部署 Jenkins 主节点与 Agent 节点,并掌握 Groovy 基础语法。
  • 生产环境应启用安全扫描与访问控制,防止未授权用户触发高危操作。

SKILL.md

Jenkins

Build, test, and deploy applications using Jenkins, the leading open-source automation server.

When to Use This Skill

Use this skill when:

  • Setting up Jenkins pipelines (declarative or scripted)
  • Configuring Jenkins agents and executors
  • Managing Jenkins plugins and security
  • Creating shared libraries for pipeline reuse
  • Integrating Jenkins with external tools

Prerequisites

  • Jenkins server (2.x or later)
  • Admin access to Jenkins
  • Java 11+ on Jenkins server
  • Basic Groovy understanding for pipelines

Declarative Pipeline

Create Jenkinsfile in repository root:

pipeline {
    agent any

    environment {
        DOCKER_REGISTRY = 'registry.example.com'
        APP_NAME = 'myapp'
    }

    stages {
        stage('Build') {
            steps {
                sh 'npm ci'
                sh 'npm run build'
            }
        }

        stage('Test') {
            steps {
                sh 'npm test'
            }
            post {
                always {
                    junit 'test-results/*.xml'
                }
            }
        }

        stage('Deploy') {
            when {
                branch 'main'
            }
            steps {
                sh './deploy.sh'
            }
        }
    }

    post {
        failure {
            mail to: 'team@example.com',
                 subject: "Pipeline Failed: ${env.JOB_NAME}",
                 body: "Check console output at ${env.BUILD_URL}"
        }
    }
}

Agent Configuration

Docker Agent

pipeline {
    agent {
        docker {
            image 'node:20'
            args '-v /tmp:/tmp'
        }
    }
    stages {
        stage('Build') {
            steps {
                sh 'npm ci && npm run build'
            }
        }
    }
}

Kubernetes Agent

pipeline {
    agent {
        kubernetes {
            yaml '''
                apiVersion: v1
                kind: Pod
                spec:
                  containers:
                  - name: node
                    image: node:20
                    command:
                    - sleep
                    args:
                    - infinity
                  - name: docker
                    image: docker:24-dind
                    securityContext:
                      privileged: true
            '''
        }
    }
    stages {
        stage('Build') {
            steps {
                container('node') {
                    sh 'npm ci && npm run build'
                }
            }
        }
    }
}

Labeled Agents

pipeline {
    agent { label 'linux && docker' }
    stages {
        stage('Build') {
            steps {
                sh 'make build'
            }
        }
    }
}

Parameters

pipeline {
    agent any

    parameters {
        string(name: 'BRANCH', defaultValue: 'main', description: 'Branch to build')
        choice(name: 'ENVIRONMENT', choices: ['dev', 'staging', 'prod'], description: 'Target environment')
        booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run tests?')
    }

    stages {
        stage('Deploy') {
            when {
                expression { params.ENVIRONMENT == 'prod' }
            }
            steps {
                sh "deploy.sh ${params.ENVIRONMENT}"
            }
        }
    }
}

Credentials

Using Credentials

pipeline {
    agent any

    environment {
        AWS_CREDS = credentials('aws-credentials')
        DOCKER_CREDS = credentials('docker-hub')
    }

    stages {
        stage('Deploy') {
            steps {
                withCredentials([
                    usernamePassword(
                        credentialsId: 'github-token',
                        usernameVariable: 'GH_USER',
                        passwordVariable: 'GH_TOKEN'
                    )
                ]) {
                    sh 'git push https://${GH_USER}:${GH_TOKEN}@github.com/repo.git'
                }
            }
        }
    }
}

Parallel Stages

pipeline {
    agent any

    stages {
        stage('Tests') {
            parallel {
                stage('Unit Tests') {
                    steps {
                        sh 'npm run test:unit'
                    }
                }
                stage('Integration Tests') {
                    steps {
                        sh 'npm run test:integration'
                    }
                }
                stage('E2E Tests') {
                    steps {
                        sh 'npm run test:e2e'
                    }
                }
            }
        }
    }
}

Shared Libraries

Library Structure

vars/
├── buildApp.groovy
├── deployApp.groovy
└── notifySlack.groovy
src/
└── com/example/
    └── Pipeline.groovy
resources/
└── templates/
    └── deployment.yaml

Define Shared Step

// vars/buildApp.groovy
def call(Map config = [:]) {
    def nodeVersion = config.nodeVersion ?: '20'

    docker.image("node:${nodeVersion}").inside {
        sh 'npm ci'
        sh 'npm run build'
    }
}

Use Shared Library

@Library('my-shared-library') _

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                buildApp(nodeVersion: '20')
            }
        }
        stage('Deploy') {
            steps {
                deployApp(environment: 'staging')
            }
        }
    }

    post {
        failure {
            notifySlack(channel: '#builds', status: 'FAILED')
        }
    }
}

Scripted Pipeline

node('linux') {
    try {
        stage('Checkout') {
            checkout scm
        }

        stage('Build') {
            docker.image('node:20').inside {
                sh 'npm ci'
                sh 'npm run build'
            }
        }

        stage('Test') {
            sh 'npm test'
        }

        if (env.BRANCH_NAME == 'main') {
            stage('Deploy') {
                sh './deploy.sh'
            }
        }
    } catch (e) {
        currentBuild.result = 'FAILURE'
        throw e
    } finally {
        cleanWs()
    }
}

Plugin Management

Essential Plugins

// Install via Jenkins CLI or init.groovy.d
def plugins = [
    'workflow-aggregator',      // Pipeline
    'git',                      // Git integration
    'docker-workflow',          // Docker Pipeline
    'kubernetes',               // Kubernetes agent
    'credentials-binding',      // Credentials
    'blueocean',               // Blue Ocean UI
    'job-dsl',                 // Job DSL
    'configuration-as-code'    // JCasC
]

Configuration as Code

# jenkins.yaml
jenkins:
  systemMessage: "Jenkins configured via JCasC"
  numExecutors: 2

  securityRealm:
    local:
      users:
        - id: admin
          password: ${ADMIN_PASSWORD}

  authorizationStrategy:
    globalMatrix:
      permissions:
        - "Overall/Administer:admin"
        - "Overall/Read:authenticated"

credentials:
  system:
    domainCredentials:
      - credentials:
          - usernamePassword:
              id: "docker-hub"
              username: "user"
              password: ${DOCKER_PASSWORD}

Multibranch Pipeline

// Automatically discovers branches with Jenkinsfile
// Configure in Jenkins UI: New Item > Multibranch Pipeline

// Branch-specific behavior in Jenkinsfile
pipeline {
    agent any

    stages {
        stage('Deploy') {
            when {
                anyOf {
                    branch 'main'
                    branch 'release/*'
                }
            }
            steps {
                sh './deploy.sh'
            }
        }
    }
}

Common Issues

Issue: Pipeline Syntax Errors

Problem: Jenkinsfile fails to parse Solution: Use Pipeline Syntax generator in Jenkins UI, validate with jenkins-cli

Issue: Agent Not Connecting

Problem: Build agents disconnect Solution: Check agent logs, verify network connectivity, increase timeout settings

Issue: Out of Memory

Problem: Jenkins crashes or builds fail with OOM Solution: Increase heap size in JAVA_OPTS, clean up old builds

Best Practices

  • Use declarative pipelines for most use cases
  • Implement shared libraries for reusable code
  • Store Jenkinsfile in source control
  • Use credentials plugin for secrets management
  • Implement proper cleanup in post blocks
  • Configure build retention policies
  • Use Blue Ocean for modern UI experience

Related Skills

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.05%
按下载量换算88

Claude

33.67%
按下载量换算87

Cursor

19.64%
按下载量换算51

Gemini CLI

9.52%
按下载量换算25

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

来源信息

继续浏览同类 Skills