根据传入的包含 TAPD 工作项源码关键字的文本或文件,将工作项状态扭转为指定状态。
String,选填,TAPD API 地址,为空时使用默认地址 https://api.tapd.cn。String,必填,TAPD 的个人访问令牌,对于 https://tapd.cn,可在 https://www.tapd.cn/personal_settings/index?tab=personal_token 生成。String ,选填,包含 TAPD 工作项源码关键字的文本。String ,选填,包含 TAPD 工作项源码关键字的文本文件。Number,必填,筛选条件,工作空间ID, 从 from_text 或 from_file 中提取工作空间ID为当前参数的工作项。String,必填,筛选条件,工作项类型。从 from_text 或 from_file 中提取类型为当前参数的工作项。可选值为 story 或 bug。String, 选填,筛选条件,工作项状态符合指定条件时,才执行更新。String,必填,将筛选后的工作项扭转为目标状态。注意:
from_text和from_file不能同时为空, 优先级from_text>from_file。
首先,在密钥仓库中新建文件存放 access_token,如 tapd.yml,内容如下:
# tapd.yml
TAPD_ACCESS_TOKEN: xxxx
# 声明允许引用该文件的仓库路径
allow_slugs: your-group/**
# .cnb.yml
dev: # 开发分支
push:
- imports: https://cnb.cool/your-group/xxx/tapd.yml # 引用密钥仓库中的文件
stages:
- name: tapd-status-helper
image: tencentcom/tapd-status-helper
settings:
access_token: $TAPD_ACCESS_TOKEN # 从密钥仓库文件中引用
from_text: $CNB_COMMIT_MESSAGE # 从 commit message 中提取
workspace_id: xxxx # 工作空间ID
type: story # 工作项类型
status: 开发中
# .cnb.yml
main: # 主分支
pull_request:
- imports: https://cnb.cool/your-group/xxx/tapd.yml # 引用密钥仓库中的文件
stages:
- name: git-commit-list
image: tencentcom/git-commit-list
settings:
toFile: commit-list.json #commit列表输出到文件中
- name: tapd-status-helper
image: tencentcom/tapd-status-helper
settings:
access_token: $TAPD_ACCESS_TOKEN # 从密钥仓库文件中引用
from_file: commit-list.json # 从上面插件输出的文件中提取
workspace_id: xxxx # 工作空间ID
type: story # 工作项类型
status: 已实现
# .cnb.yml
$: # 兜底所有tag名
tag_push:
- imports: https://cnb.cool/your-group/xxx/tapd.yml # 引用密钥仓库中的文件
stages:
- name: git-commit-list
image: tencentcom/git-commit-list
settings:
tagFormat: v* # 筛选符合tagFormat的上一个tag
toFile: commit-list.json #commit列表输出到文件中
- name: tapd-status-helper
image: tencentcom/tapd-status-helper
settings:
access_token: $TAPD_ACCESS_TOKEN # 从密钥仓库文件中引用
from_file: commit-list.json # 从上面插件输出的文件中提取
workspace_id: xxxx # 工作空间ID
type: story # 工作项类型
status: 已完成
docker run --rm \
-e TZ=Asia/Shanghai \
-e PLUGIN_ACCESS_TOKEN='xxx' \
-e PLUGIN_WORKSPACE_ID='xxx' \
-e PLUGIN_ENDPOINT='https://api.tapd.cn' \
-e PLUGIN_FROM_TEXT="xxx" \
-e PLUGIN_STATUS='test' \
-e PLUGIN_TYPE='story' \
-v $(pwd):$(pwd) \
-w $(pwd) \
tapd-status-helper