|
| 1 | +--- |
| 2 | +sidebar_position: 2 |
| 3 | +--- |
| 4 | + |
| 5 | + |
| 6 | +# Teambition 集成 |
| 7 | + |
| 8 | +## 简介 |
| 9 | +配置 Teambition 集成后,可将项目的通用任务同步至 Teambition,实现企业工单平台对任务的统一管理。以下是典型的使用场景: |
| 10 | +1. 设备发生问题时,自动上传数据并在 Teambition 中创建任务 |
| 11 | +2. 可视化分析数据时,在关键时间点创建任务并同步至 Teambition |
| 12 | + |
| 13 | +## 前提条件 |
| 14 | +请确保你的 Teambition 企业已发布「企业内部应用」,步骤如下: |
| 15 | + |
| 16 | +1. 进入[Teambition 开放平台](https://open.teambition.com/app),创建新应用-企业内部应用,详见[Teambition 发布应用文档](https://open.teambition.com/docs/documents/5d89d63f8acc9d00143ac733) |
| 17 | +2. 进入应用开发 - 权限管理页面,开通以下权限 |
| 18 | + |
| 19 | +| 开通项 | 图示 | |
| 20 | +|------|------| |
| 21 | +| 任务-任务查看权限 |  | |
| 22 | +| 任务-任务创建权限 |  | |
| 23 | +| 项目-项目查看权限 |  | |
| 24 | +| 项目-获取缺陷分类列表 |  | |
| 25 | +| 工作流节点-搜索企业工作流 |  | |
| 26 | + |
| 27 | +3. 在应用发布页面发布应用,并联系企业管理员进行审核 |
| 28 | +4. 在应用凭证与基本信息页面,复制应用的 App ID 与 App Secret,用于后续项目集成 |
| 29 | + |
| 30 | +## 操作流程 |
| 31 | +### 配置集成 |
| 32 | +> 仅项目管理员与组织管理员有编辑权限,其余角色不可见 |
| 33 | +
|
| 34 | +1. 进入需要配置集成的项目,在项目设置 - 服务集成 - Teambition 中,点击【添加配置】按钮。 |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +2. 填写集成配置并保存,字段说明如下 |
| 39 | + |
| 40 | +```yaml |
| 41 | +enabled: true # 启用配置 |
| 42 | +endpoint: https://teambition.com # Teambition 应用的网页地址 |
| 43 | +apiEndpoint: https://open.teambition.com/api/ # Teambition API 地址 |
| 44 | +appCredential: |
| 45 | + appId: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 应用的唯一标识符(App ID) |
| 46 | + appSecret: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 应用的安全密钥(App Secret) |
| 47 | +userId: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 任务创建者的 UID |
| 48 | +orgId: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 的组织 ID |
| 49 | +projectId: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 的项目 ID |
| 50 | + |
| 51 | +issueTitleTemplate: '{{task.title}}' # Teambition 的标题为任务名称 |
| 52 | +issueDescriptionTemplate: | |
| 53 | + 【任务名称】:{{task.title}} |
| 54 | + 【记录名称】:{{record.title}} |
| 55 | + 【记录描述】:{{record.description}} |
| 56 | + 【记录标签】:{{record.labels}} |
| 57 | + 【设备 ID】:{{device.id}} |
| 58 | + 【记录链接】:{{record.link}} |
| 59 | +assignee: '{{moment.customFields.assignee}}' # Teambition 任务执行者的 UID,取自一刻属性值中 assignee 对应的值 |
| 60 | +deadline: '{{moment.triggerTime}}' # Teambition 任务的截止时间,取自一刻的触发时间 |
| 61 | +sprintId: '{{device.customFields.sprint}}' # Teambition 的迭代 ID,取自设备自定义字段 sprint 的值 |
| 62 | +scenarioFieldConfigId: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 任务类型(需求/缺陷/任务)的 ID |
| 63 | +customFields: |
| 64 | + - id: xxxxxxxxxxxxxxxxxxxxxxxx # Teambition 自定义字段的 ID |
| 65 | + type: commongroup # Teambition 自定义字段的类型 |
| 66 | + values: |
| 67 | + - title: '{{moment.customFields.bug}}' # Teambition 自定义字段的值,取自一刻属性值中 bug 对应的值 |
| 68 | + |
| 69 | +``` |
| 70 | + |
| 71 | +- **enabled** |
| 72 | + |
| 73 | + 是否启用配置,默认为`true` |
| 74 | + |
| 75 | +- **endpoint** |
| 76 | + |
| 77 | + Teambition 应用的网页地址,默认为`https://teambition.com` |
| 78 | + |
| 79 | +- **apiEndpoint** |
| 80 | + |
| 81 | + Teambition API 地址,默认为`https://open.teambition.com/api/` |
| 82 | + |
| 83 | +- **appId** |
| 84 | + |
| 85 | + Teambition 应用的唯一标识符(App ID),可在[Teambition 开放平台](https://open.teambition.com/app)的「应用凭证与基础信息」页获取。 |
| 86 | + |
| 87 | +- **appSecret** |
| 88 | + |
| 89 | + Teambition 应用的安全密钥(App Secret),可在[Teambition 开放平台](https://open.teambition.com/app)的「应用凭证与基础信息」页获取。 |
| 90 | + |
| 91 | +  |
| 92 | + |
| 93 | +- **userId** |
| 94 | + |
| 95 | + Teambition 任务创建者的 UID,可在账号设置-个人账号中心获取。 |
| 96 | + |
| 97 | + |  |  | |
| 98 | + |:---:|:---:| |
| 99 | + |
| 100 | +- **orgId** |
| 101 | + |
| 102 | + Teambition 的组织 ID,可在浏览器的 URL 中获取。 |
| 103 | + |
| 104 | +  |
| 105 | + |
| 106 | +- **projectId** |
| 107 | + |
| 108 | + Teambition 的项目 ID,可进入项目后,在浏览器的 URL 中获取。 |
| 109 | + |
| 110 | +  |
| 111 | + |
| 112 | +- **issueTitleTemplate** |
| 113 | + |
| 114 | + Teambition 任务标题,可自定义,默认使用通用任务标题,即`'{{task.title}}'` |
| 115 | + |
| 116 | +- **issueDescriptionTemplate** |
| 117 | + |
| 118 | + Teambition 任务备注,可自定义或使用变量 |
| 119 | + |
| 120 | +- **assignee** |
| 121 | + |
| 122 | + Teambition 任务执行者的 UID,可在账号设置-个人账号中心获取(同userId)。 |
| 123 | + |
| 124 | +- **deadline** |
| 125 | + |
| 126 | + Teambition 任务的截止时间,默认为一刻的触发时间,即`'{{moment.triggerTime}}'` |
| 127 | + |
| 128 | +- **sprintId** |
| 129 | + |
| 130 | + Teambition 任务的迭代 ID,可进入项目的迭代,在浏览器的 URL 处获取。 |
| 131 | + |
| 132 | +- **scenarioFieldConfigId** |
| 133 | + |
| 134 | + Teambition 任务类型(需求/缺陷/任务),在项目中打开浏览器开发者模式,可获取对应的 id。 |
| 135 | + |
| 136 | +  |
| 137 | + |
| 138 | +- **customFields** |
| 139 | + |
| 140 | + Teambition 任务的自定义字段,一个自定义字段的配置信息如下: |
| 141 | + |
| 142 | + ```yaml |
| 143 | + - id: 67b****e93d23d # 自定义字段的 ID |
| 144 | + values: |
| 145 | + - title: **** # 自定义字段的值 |
| 146 | + ``` |
| 147 | + |
| 148 | + - 自定义字段的 ID 可在浏览器开发者模式中获取 |
| 149 | + |
| 150 | +  |
| 151 | +
|
| 152 | + - 自定义字段的值可自定义或使用变量 |
| 153 | +
|
| 154 | + - 其中,「缺陷分类」字段需增加字段类型`type: commongroup` |
| 155 | + |
| 156 | + ```yaml |
| 157 | + customFields: |
| 158 | + - id: 67b2c****015 # 字段的 ID |
| 159 | + type: commongroup # 字段类型,若为其他自定义字段,无需填写此行 |
| 160 | + values: |
| 161 | + - title: **** # 字段的值 |
| 162 | + ``` |
| 163 | + |
| 164 | +### 变量 |
| 165 | +集成中的任务信息支持使用变量,详见下表: |
| 166 | + |
| 167 | +| 变量名 | 含义 | |
| 168 | +|--------|------| |
| 169 | +| `{{task.title}}` | 任务名称 | |
| 170 | +| `{{record.title}}` | 记录名称 | |
| 171 | +| `{{record.description}}` | 记录描述 | |
| 172 | +| `{{record.labels}}` | 记录标签 | |
| 173 | +| `{{record.link}}` | 记录链接 | |
| 174 | +| `{{device.id}}` | 设备 ID | |
| 175 | +| `{{device.title}}` | 设备名称 | |
| 176 | +| `{{device.customFields.sprint}}` | 设备自定义字段`sprint`的值 | |
| 177 | +| `{{moment.customFields.name}}` | 一刻属性值中`name`字段的值 | |
| 178 | +| `{{moment.triggerTime}}` | 一刻的触发时间 | |
| 179 | + |
| 180 | +### 同步任务到 Teambition |
| 181 | +1. 前往已配置的数采&诊断规则中,将「诊断数据」模块中的「创建通用任务」与「同步通用任务至 Teambition 中」设置为「是」 |
| 182 | + |
| 183 | +  |
| 184 | + |
| 185 | +2. 当监听到设备触发规则时,将自动上传数据并在 Teambition 中创建任务 |
| 186 | + - 根据规则采集的数据 |
| 187 | + |
| 188 | +  |
| 189 | + |
| 190 | + - 自动诊断数据,并创建出一刻 |
| 191 | + |
| 192 | +  |
| 193 | + |
| 194 | + - 根据创建出来的一刻,系统自动创建「通用任务」并同步到 Teambition 平台中 |
| 195 | + |
| 196 | +  |
| 197 | + |
| 198 | + - 在 Teambition 中可查看到一条任务 |
| 199 | + |
| 200 | +  |
| 201 | + |
| 202 | +## 常见问题解答 |
| 203 | +**问:Teambition 中的 userId 出现了文本溢出,无法直接在界面上复制,怎么办?** |
| 204 | +答:使用浏览器的开发者模式查看 userID,在 Network - me - id ,复制双引号中间的部分即可,详细操作如下图所示。 |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | +**问:保存 Teambition 集成时,提示「请检查 yaml 文件格式」?** |
| 209 | +答:检查 yaml 内容中使用变量的部分,是否已使用英文输入法的单引号 ' ' 括起,如下图所示的`'{{moment.triggerTime}}'`就少了右边部分的单引号。 |
| 210 | + |
| 211 | + |
0 commit comments