logo
0
0
Login
docs: 增加tag_push例子

tapd-status-helper

介绍

根据传入的包含 TAPD 工作项源码关键字的文本或文件,将工作项状态扭转为指定状态。

参数

  • endpoint: String,选填,TAPD API 地址,为空时使用默认地址 https://api.tapd.cn
  • access_token: String,必填,TAPD 的个人访问令牌,对于 https://tapd.cn,可在 https://www.tapd.cn/personal_settings/index?tab=personal_token 生成。
  • from_text: String ,选填,包含 TAPD 工作项源码关键字的文本。
  • from_file: String ,选填,包含 TAPD 工作项源码关键字的文本文件。
  • workspace_id: Number,必填,筛选条件,工作空间ID, 从 from_textfrom_file 中提取工作空间ID为当前参数的工作项。
  • type: String,必填,筛选条件,工作项类型。从 from_textfrom_file 中提取类型为当前参数的工作项。可选值为 storybug
  • when: String, 选填,筛选条件,工作项状态符合指定条件时,才执行更新。
  • status: String,必填,将筛选后的工作项扭转为目标状态。

注意:from_textfrom_file 不能同时为空, 优先级 from_text > from_file

在 云原生构建 中使用

首先,在密钥仓库中新建文件存放 access_token,如 tapd.yml,内容如下:

# tapd.yml TAPD_ACCESS_TOKEN: xxxx # 声明允许引用该文件的仓库路径 allow_slugs: your-group/**

在 push 事件中使用

# .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: 开发中

在 pull_request 事件中使用

# .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: 已实现

在 tag_push 事件中使用

# .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 中使用

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