一个用于CI/CD流水线的CNB Issue属性更新插件,使用CNB OpenAPI批量更新Issue的自定义属性。
在 .cnb.yml 中配置:
main:
push:
- stages:
- name: issue-property-updater
image: cnbcool/issue-property-updater:latest
settings:
# CNB API端点URL, 不填则取默认环境变量 CNB_API_ENDPOINT 的值
cnb_api_endpoint: https://api.cnb.cool
# CNB API访问token, 不填则取默认环境变量 CNB_TOKEN 的值
token: your-api-token
# 仓库slug, 不填则取默认环境变量 CNB_REPO_SLUG 的值
repo_slug: my_slug/my-repo
# 属性更新配置(JSON数组)
properties: '[["#123","status","done"]]'
| 参数名 | 描述 | 示例 |
|---|---|---|
cnb_api_endpoint | CNB API端点URL, 不填则取默认环境变量 CNB_API_ENDPOINT 的值 | https://api.cnb.cool |
token | CNB API访问token, 不填则取默认环境变量 CNB_TOKEN 的值 | your-api-token-here |
repo_slug | 仓库slug, 不填则取默认环境变量 CNB_REPO_SLUG 的值 | my-repo |
properties | 属性更新配置(JSON数组) | [["#123","status","done"]] |
[["#123","status","done"],["repo#456","status","in_progress"]]
"#123" - 使用默认仓库"repo#456" - 指定仓库[
{
"repo": "my-group/my-repo",
"issueNumber": 123,
"key": "status",
"value": "done"
}
]
# 设置环境变量
export PLUGIN_CNB_API_ENDPOINT="https://api.cnb.cool"
export PLUGIN_CNB_TOKEN="your-api-token"
export PLUGIN_REPO_SLUG="my-repo"
export PLUGIN_PROPERTIES='[["#123","status","done"]]'
# 运行插件
bun src/cli/index.ts
export PLUGIN_PROPERTIES='[
["#123","status","done"],
["#124","status","in_progress"],
["#125","priority","high"]
]'
bun src/cli/index.ts
export PLUGIN_PROPERTIES='[
["repo1#123","status","done"],
["repo2#456","status","in_progress"],
["my-default-repo#789","priority","high"]
]'
bun src/cli/index.ts
bun src/cli/index.ts --verbose --debug
| 选项 | 描述 |
|---|---|
-h, --help | 显示帮助信息 |
--version | 显示版本信息 |
-v, --verbose | 启用详细日志输出 |
-d, --debug | 启用调试模式 |
{
"status": "success",
"updated": 3,
"failed": 0,
"issues": [
{
"issue": "#123",
"key": "status",
"success": true
}
],
"totalTime": 1250
}
{
"timestamp": "2026-01-27T10:30:00.000Z",
"level": "error",
"message": "API请求失败",
"statusCode": 404,
"retryAttempted": 1,
"issue": "#456",
"key": "status"
}
| 退出码 | 含义 |
|---|---|
| 0 | 成功(所有属性更新成功) |
| 1 | 失败(至少一个属性更新失败) |
| 2 | 配置错误 |
| 3 | API错误 |
| 4 | 网络错误 |
[["#123","status","A"],["#123","status","B"]] → 最终值为"B"# 安装依赖
bun install
# 运行类型检查
bun run typecheck
# 运行linter
bun run lint
# 格式化代码
bun run format
# 构建项目
bun run build
docker build -t cnbcool/issue-property-updater:dev .
docker run --rm \
-e PLUGIN_CNB_API_ENDPOINT="https://api.cnb.cool" \
-e PLUGIN_CNB_TOKEN="your-api-token" \
-e PLUGIN_REPO_SLUG="my-org/my-repo" \
-e PLUGIN_PROPERTIES='[["#123","status","done"]]' \
-v "$(pwd):/workspace" \
-w /workspace \
cnbcool/issue-property-updater:dev
MIT