SuperAPI AI Directory

jenkins-deploy

Deployment & operations

View repository

Updated 10-15 11:02

About this skill

ABC Jenkins Release Skill

Interactively trigger Jenkins builds, with support for intelligent parameter inference (automatic branch name parsing, environment inference) and real-time status monitoring.

Prerequisites

  1. JENKINS_USER Environment variable is set (Jenkins username)
  2. JENKINS_TOKEN Environment variable is set (Jenkins API Token)
  3. Currently in a Git repository (used to automatically obtain branches and tags)

Installation

npx add-skill https://github.com/ABCFed/claude-marketplace/tree/main/skills/jenkins-deploy

Preparation

# 编辑 ~/.zshrc 或 ~/.bashrc
export JENKINS_USER="your_jenkins_username"
export JENKINS_TOKEN="your_jenkins_api_token"
source ~/.zshrc

Usage Flow

Method 1: Two-stage deployment (recommended, progress visible)

Step 1: Trigger the build (returns JSON)

python scripts/jenkins_deploy.py \
  <project_name> \
  --trigger-only-no-monitor \
  --yes \
  --params "<json>"

Returns JSON:

{
  "queue_id": 161484,
  "full_name": "abc-his/test/PcFeatureTest",
  "project_name": "PcFeatureTest",
  "build_url": "http://ci.abczs.cn/job/abc-his/job/test/job/PcFeatureTest/"
}

Step 2: Start background monitoring

Claude Code (use run_in_background=true):

# 在 Claude Code 中使用 Bash 工具,设置 run_in_background=true
python scripts/jenkins_deploy.py \
  --monitor-only \
  --full-name abc-his/test/PcFeatureTest \
  --queue-id 161484 \
  --display-name PcFeatureTest

Other AI tools or terminals (use nohup):

nohup python scripts/jenkins_deploy.py \
  --monitor-only \
  --full-name abc-his/test/PcFeatureTest \
  --queue-id 161484 \
  --display-name PcFeatureTest > /dev/null 2>&1 &

Important notes:

  • The monitoring task runs as abackground task,without blocking the main conversation/terminal
  • Claude Code: progress is displayed in the background task output
  • Other tools: use nohup for background execution; a system notification will be received after the build completes
  • The user can continue with other operations

Monitoring output example:

📊 开始监控构建: PcFeatureTest
   Queue ID: 161484
   项目: abc-his/test/PcFeatureTest

任务开始执行 (Build #11122)
📦 构建号: #11122
⏳ 监控构建进度...
   需要取消时,请告诉我: "取消构建 #11122"

⏳ [███████████░░░░░░░░░░░░░░░] 42% (125s)
...
✅ PcFeatureTest 构建成功!

Parameter Description

--trigger-only-no-monitor mode (trigger build)

Parameter Required Description
project_name ✓ Jenkins project name (e.g., PcFeatureTest)
--trigger-only-no-monitor ✓ Only trigger the build, do not start monitoring, return JSON
--yes ✓ Skip interactive confirmation
--params ✓ Complete build parameters in JSON format

--monitor-only mode

Parameter Required Description
--monitor-only ✓ Background monitoring mode
--full-name ✓ Full project path (e.g., abc-his/test/PcFeatureTest)
--queue-id ✓ Queue ID
--display-name ✓ Project display name (used for notifications)

Complete Examples

Test environment release

# 步骤 1: 触发构建
python scripts/jenkins_deploy.py \
  PcFeatureTest \
  --trigger-only-no-monitor \
  --yes \
  --params '{"repoTag":"pc-t2025.53.19","tapdId":"1167459320001118371","featureNo":"70"}'

# 返回 JSON:
# {"queue_id": 161484, "full_name": "abc-his/test/PcFeatureTest", ...}

# 步骤 2: 启动后台监控
# Claude Code: 直接运行(会使用 run_in_background=true)
# 其他工具: 添加 nohup 和 & 放到后台
python scripts/jenkins_deploy.py \
  --monitor-only \
  --full-name abc-his/test/PcFeatureTest \
  --queue-id 161484 \
  --display-name PcFeatureTest

Development environment release

python scripts/jenkins_deploy.py \
  staticPcOwn \
  --trigger-only-no-monitor \
  --yes \
  --params '{"repoBranch":"hotfix/xxx-1167459320001118371"}'

Other Commands

# 列出所有项目
python scripts/jenkins_deploy.py --list --all

# 列出当前仓库相关的项目(自动过滤)
python scripts/jenkins_deploy.py --list

# 停止指定构建号
python scripts/jenkins_deploy.py --stop <build_number>

Testing and Verification

After each skill modification, it is recommended to verify using the following process:

Quick test command

# 自动化运行所有测试用例
python scripts/run_tests.py

Manual testing

1. Parameter validation (required)

python scripts/jenkins_deploy.py \
  PcFeatureTest \
  --validate \
  --params '{"repoTag":"pc-t2025.53.19","featureNo":"70"}'

2. Dry run (required)

python scripts/jenkins_deploy.py \
  PcFeatureTest \
  --dry-run \
  --params '{"repoTag":"pc-t2025.53.19","featureNo":"70"}'

Detailed test cases: see test-cases.md

Workflow (recommended mode)

┌─────────────────────────────────────────────────────────────┐
│ 1. Claude Code: 使用 AskUserQuestion 收集参数               │
│    其他 AI 工具: 通过对话收集参数                            │
│    - 项目名称                                               │
│    - Git 分支 / 标签                                         │
│    - TAPD ID(从分支名自动解析)                             │
│    - featureNo(如果项目有此参数,**必填**)                 │
│    - 其他构建参数                                            │
└─────────────────────────────────────────────────────────────┘
                          ↓
┌─────────────────────────────────────────────────────────────┐
│ 2. 调用脚本 --trigger-only 模式                            │
│    - 传递完整的 JSON 参数                                    │
│    - 直接触发 Jenkins API                                   │
└─────────────────────────────────────────────────────────────┘
                          ↓
┌─────────────────────────────────────────────────────────────┐
│ 3. 返回构建信息                                            │
│    - Queue ID                                               │
│    - 构建页面 URL                                           │
└─────────────────────────────────────────────────────────────┘

Intelligent Parameter Inference

Parameter Inference rule Example
repoBranch Current Git branch hotfix/盘点页面增加备注及搜索-1167459320001118371
repoTag Latest Git tag pc-f2026.05.48
tapdId / tapdid Automatically parsed from the branch name (standardized process: the number at the end of the branch name) 1167459320001118371
execType tag=deploy if present, build if no tag with tag → deploy
featureNo Required (when the project has this parameter), must be explicitly specified by the user 1122044681001112866
envNo Required by some projects, must be explicitly specified by the user 001

TAPD ID Auto-parsing

Under the standardized process, the branch name format is feature/xxx-{TAPD_ID} or hotfix/xxx-{TAPD_ID}:

分支名:hotfix/盘点页面增加备注及搜索-1167459320001118371
                                         └────────────────────┘
                                          自动提取 TAPD ID

No manual configuration is required; it will be automatically populated into tapdId or tapdid parameter during release.

⚠️ Important:

  • featureNo(Feature Number):Required when the project has this parameter, must be provided by the user
  • envNo(Environment Number): Required for some projects, must be provided by the user

Supported Parameter Types

Parameter Type Description Interaction Method
StringParameterDefinition Text Input Enter directly or press Enter to use the default value
ChoiceParameterDefinition Dropdown Selection Display option list, enter a number to select
PT_CHECKBOX Checkbox Multi-select Display option list, enter comma-separated numbers
BooleanParameterDefinition Boolean Value y/n selection
WReadonlyStringParameterDefinition Read-only Parameter Used automatically, cannot be modified

Common Project Types

Detailed Project Parameter Reference: See projects.md

1. PcFeatureTest (Test Environment Release)

Purpose: Release to the test environment using a tag

Key Parameters:

  • repoTag: Release tag (e.g., pc-t2025.53.19)
  • tapdId: TAPD requirement ID (automatically parsed from the branch name)
  • featureNo:Feature Number (required), must be provided by the user
  • buildEnv: Fixed as test

Example:

python scripts/jenkins_deploy.py \
  PcFeatureTest \
  --trigger-only \
  --params '{"repoTag":"pc-f2026.05.48","tapdId":"1167459320001118371","featureNo":"1122044681001112866"}'

2. staticPcOwn (Development Environment Release)

Purpose: Release to the development environment using a branch

Key Parameters:

  • repoBranch: Release branch (e.g., hotfix/xxx-1167459320001118371)
  • dockerTag: Docker image tag (default latest)
  • buildEnv: Fixed as dev

Example:

python scripts/jenkins_deploy.py staticPcOwn

3. static-mf-deepseek (Microservice Release)

Purpose: Microservice project release, supports multi-region deployment

Key Parameters:

  • projectRootDir: Project subdirectory (e.g., packages/mf-deepseek)
  • deployZone: Deployment region (checkbox:primary / standby)
  • repoBranch: Release branch

Example:

python scripts/jenkins_deploy.py static-mf-deepseek

Caching Mechanism

Cache location: scripts/cache/jobs.json

Cache strategy:

  • First run: Fetch 542 projects from the Jenkins API and cache them
  • Subsequent runs: Use the cache directly (fast)
  • Force refresh: Use the --refresh parameter

Manually clear cache:

rm scripts/cache/jobs.json

Supported Jenkins Environments

Environment Dev Test
abc-his ✓ ✓
abc-bis ✓ ✓
abc-cooperation ✓ ✓
abc-global ✓ ✓
abc-oa ✓ ✓
mira ✓ ✓

Error Handling

Scenario Handling Method
Authentication not configured Prompt to set JENKINS_USER and JENKINS_TOKEN
Project does not exist List available projects
Missing featureNo If the project has this parameter, the user must be prompted to provide it
Build failed Display the build URL and log link
Parameter validation failed Prompt the correct format
Network timeout Prompt to check the network connection

Trigger Keywords

Jenkins, release, deployment, build, Deploy, Build, CI/CD