jenkins
它能做什么
这个工具可以帮你创建和管理自动化流程,用于构建、测试和交付软件。你可以设置这些任务在哪里、以什么方式运行,还可以管理插件来扩展功能。
适用场景
- ✓当你需要设置一个自动编译和测试代码的工作流时。
- ✓当你需要指定自动化任务在哪里运行(比如某台特定机器或容器)时。
- ✓当你想为自动化系统添加新功能(比如与其他工具集成)时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/jenkins/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“如何设置一个流水线,在 Docker 容器中构建并测试 Node.js 项目?”
每周 5 个新技能,1 分钟读完。
工作原理
你需要在配置文件中定义流程的各个步骤。工具会按顺序或并行执行这些步骤,并使用你指定的 agent(机器或容器)来运行任务。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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'
…
常见问题
什么是“流水线”(pipeline)?
它是一系列自动执行的步骤,用于构建、测试和交付软件。
什么是 “agent”?
它是运行流水线任务的环境,可以是机器或容器。
什么是“插件”(plugins)?
它们是用来为自动化系统添加新功能的扩展程序。
详情
作者的原始描述
Create and manage Jenkins CI/CD pipelines, configure agents, manage plugins, and automate builds.
热度
- GitHub 星标
- 48k
- 排名
- #4987
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。