基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill cicd-jenkins命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | cicd-jenkins |
| description | Jenkins — declarative Jenkinsfile for build, test, and deploy. |
// Jenkinsfile
pipeline {
agent {
docker {
image 'node:20-alpine'
args '-v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
REGISTRY = credentials('docker-registry-url')
DEPLOY_KEY = credentials('deploy-ssh-key')
}
options {
timeout(time: 30, unit: 'MINUTES')
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
stages {
stage('Install') {
steps {
sh 'npm ci'
}
}
stage('Lint') {
steps {
sh 'npm run lint'
}
}
stage('Test') {
steps {
sh 'npm test'
}
post {
always {
junit 'test-results/*.xml'
}
}
}
stage('Build Image') {
when {
branch 'main'
}
steps {
sh "docker build -t ${REGISTRY}/myapp:${GIT_COMMIT} ."
sh "docker push ${REGISTRY}/myapp:${GIT_COMMIT}"
}
}
stage('Deploy') {
when {
branch 'main'
}
input {
message 'Deploy to production?'
ok 'Deploy'
}
steps {
sshagent(['deploy-ssh-key']) {
sh """
ssh -o StrictHostKeyChecking=no deploy@${DEPLOY_HOST} '
cd /opt/myapp &&
IMAGE_TAG=${GIT_COMMIT} docker compose pull app &&
IMAGE_TAG=${GIT_COMMIT} docker compose up -d &&
docker image prune -f
'
"""
}
}
}
}
post {
failure {
mail to: 'team@example.com',
subject: "Pipeline failed: ${env.JOB_NAME}",
body: "Build ${env.BUILD_URL} failed."
}
}
}
credentials() binding or withCredentials blockset +x if you must debugwithCredentials([usernamePassword(
credentialsId: 'docker-registry',
usernameVariable: 'DOCKER_USER',
passwordVariable: 'DOCKER_PASS'
)]) {
sh 'docker login -u $DOCKER_USER -p $DOCKER_PASS'
}
For reusable pipeline logic across repositories:
// Jenkinsfile
@Library('my-shared-library') _
deployApp(environment: 'production', image: 'myapp')
agent { docker {} } to run in containers — no environment pollutiondisableConcurrentBuilds() prevents race conditions on shared resourcesbuildDiscarder prevents disk exhaustion from keeping old buildsinput for manual approval gates before production deploystimeout to prevent stuck builds from blocking the executorpost { always {} } for test report publishing — runs even on failure