工作流

本文主要介绍如何使用 Open API 来操作 Zadig 的工作流。

工作流

获取工作流列表

请求

  1. GET /openapi/workflows?projectKey=<项目标识>&viewName=<视图名称>

Query

参数名类型描述是否必须默认值
projectKeystring项目标识
viewNamestring工作流视图名称

返回说明

参数名类型描述
workflows[]workflow工作流列表

workflow

参数名类型描述
workflow_keystring工作流标识
workflow_namestring工作流名称
update_bystring更新者
update_timeint更新时间
typestring工作流类型,有以下两种类型:”product”: 产品工作流”; custom”: 自定义工作流

成功返回

点击查看

  1. {
  2. "workflows": [
  3. {
  4. "workflow_key": "just-deploy",
  5. "workflow_name": "just-deploy",
  6. "update_by": "admin",
  7. "update_time": 1686217885,
  8. "type": "custom"
  9. },
  10. {
  11. "workflow_key": "xiaxianfuwu",
  12. "workflow_name": "下线服务",
  13. "update_by": "admin",
  14. "update_time": 1686193453,
  15. "type": "custom"
  16. }
  17. ]
  18. }

获取工作流详情

请求

  1. GET /openapi/workflows/custom/{workflowKey}/detail?projectKey=<项目标识>

Query

参数名类型描述是否必须默认值
projectKeystring项目标识

路径参数说明

参数名类型描述是否必须默认值
workflowKeystring工作流标识

成功返回

点击查看

  1. {
  2. "workflow_key": "build-deploy", // 工作流标识
  3. "workflow_name": "build-deploy", // 工作流名称
  4. "project_key": "lilian-test", // 项目标识
  5. "description": "", // 工作流描述
  6. "created_by": "admin", // 创建者
  7. "create_time": 1686192946, // 创建时间
  8. "updated_by": "", // 更新者
  9. "update_time": 1690180684, // 更新时间
  10. "params": [ // 工作流参数列表
  11. {
  12. "name": "code",
  13. "description": "",
  14. "type": "repo",
  15. "value": "",
  16. "repo": {
  17. "source": "gitee",
  18. "repo_owner": "liyue326",
  19. "repo_namespace": "liyue326",
  20. "repo_name": "picture",
  21. "remote_name": "origin",
  22. "branch": "master",
  23. "hidden": false,
  24. "is_primary": false,
  25. "codehost_id": 4,
  26. "oauth_token": "",
  27. "address": "",
  28. "source_from": "",
  29. "param_name": "",
  30. "job_name": "",
  31. "service_name": "",
  32. "service_module": "",
  33. "repo_index": 0,
  34. "submission_id": ""
  35. },
  36. "default": "",
  37. "is_credential": false
  38. },
  39. {
  40. "name": "name",
  41. "description": "",
  42. "type": "string",
  43. "value": "build",
  44. "repo": null,
  45. "default": "",
  46. "is_credential": false
  47. }
  48. ],
  49. "stages": [ // 工作流阶段列表
  50. {
  51. "name": "build", // 阶段名称
  52. "parallel": true, // 是否并发运行
  53. "approval": { // 审批信息
  54. "enabled": false,
  55. "type": "native",
  56. "description": "",
  57. "native_approval": {
  58. "Timeout": 5,
  59. "approve_users": [],
  60. "NeededApprovers": 0
  61. },
  62. "dingtalk_approval": {
  63. "Timeout": 5
  64. }
  65. },
  66. "jobs": [ // 工作流job列表
  67. {
  68. "name": "build", // job名称
  69. "type": "zadig-build", // job类型
  70. "skipped": false, // 是否执行
  71. "spec": { // job详细信息
  72. "docker_registry_id": "630c7ad700430c131062e245",
  73. "service_and_builds": [
  74. {
  75. "build_name": "openapi-build",
  76. "image": "",
  77. "image_name": "service1",
  78. "key_vals": [],
  79. "repos": [],
  80. "service_module": "service1",
  81. "service_name": "service1",
  82. "share_storage_info": null
  83. }
  84. ]
  85. },
  86. "run_policy": "",
  87. "service_modules": []
  88. }
  89. ]
  90. },
  91. {
  92. "name": "deploy",
  93. "parallel": true,
  94. "approval": {
  95. "enabled": false,
  96. "type": "native",
  97. "description": "",
  98. "native_approval": {
  99. "Timeout": 5,
  100. "approve_users": [],
  101. "NeededApprovers": 0
  102. },
  103. "dingtalk_approval": {
  104. "Timeout": 5
  105. }
  106. },
  107. "jobs": [
  108. {
  109. "name": "deploy",
  110. "type": "zadig-deploy",
  111. "skipped": false,
  112. "spec": {
  113. "deploy_contents": [
  114. "image",
  115. "vars"
  116. ],
  117. "deploy_type": "",
  118. "env": "dev",
  119. "job_name": "build",
  120. "origin_job_name": "",
  121. "production": false,
  122. "service_and_images": [],
  123. "services": [
  124. {
  125. "key_vals": [],
  126. "latest_key_vals": [],
  127. "latest_variable_kvs": [],
  128. "service_name": "service2",
  129. "updatable": false,
  130. "update_config": false,
  131. "variable_configs": [],
  132. "variable_kvs": [],
  133. "variable_yaml": ""
  134. },
  135. {
  136. "key_vals": [],
  137. "latest_key_vals": [],
  138. "latest_variable_kvs": [],
  139. "service_name": "service1",
  140. "updatable": true,
  141. "update_config": false,
  142. "variable_configs": [
  143. {
  144. "use_global_variable": false,
  145. "variable_key": "cpuLimit"
  146. },
  147. {
  148. "use_global_variable": false,
  149. "variable_key": "memoryLimit"
  150. },
  151. {
  152. "use_global_variable": false,
  153. "variable_key": "port"
  154. }
  155. ],
  156. "variable_kvs": [],
  157. "variable_yaml": ""
  158. }
  159. ],
  160. "skip_check_run_status": false,
  161. "source": "fromjob"
  162. },
  163. "run_policy": "",
  164. "service_modules": []
  165. },
  166. {
  167. "name": "default",
  168. "type": "plugin",
  169. "skipped": false,
  170. "spec": {
  171. "plugin": {
  172. "args": [
  173. "echo $(inputs.CONTENT)"
  174. ],
  175. "category": "",
  176. "cmds": [
  177. "/bin/sh",
  178. "-c"
  179. ],
  180. "description": "hello world",
  181. "envs": [
  182. {
  183. "name": "CONTENT",
  184. "value": "$(inputs.CONTENT)"
  185. }
  186. ],
  187. "image": "alpine/curl:3.14",
  188. "inputs": [
  189. {
  190. "default": "hello world",
  191. "description": "content to print",
  192. "is_credential": false,
  193. "name": "CONTENT",
  194. "repo": null,
  195. "type": "string",
  196. "value": "hello world"
  197. }
  198. ],
  199. "is_offical": false,
  200. "name": "hello-world",
  201. "outputs": [],
  202. "repo_url": "",
  203. "version": "v0.0.1"
  204. },
  205. "properties": {
  206. "build_os": "",
  207. "cache": {
  208. "medium_type": "",
  209. "nfs_properties": {
  210. "provision_type": "",
  211. "pvc": "",
  212. "storage_class": "",
  213. "storage_size_in_gib": 0,
  214. "subpath": ""
  215. },
  216. "object_properties": {
  217. "id": ""
  218. }
  219. },
  220. "cache_dir_type": "",
  221. "cache_enable": false,
  222. "cache_user_dir": "",
  223. "cluster_id": "",
  224. "custom_envs": [],
  225. "envs": [],
  226. "image_from": "",
  227. "image_id": "",
  228. "log_file_name": "",
  229. "namespace": "",
  230. "params": [],
  231. "registries": [],
  232. "res_req": "low",
  233. "res_req_spec": {
  234. "cpu_limit": 1000,
  235. "gpu_limit": "",
  236. "memory_limit": 512
  237. },
  238. "retry": 0,
  239. "share_storage_details": [],
  240. "timeout": 60
  241. }
  242. },
  243. "run_policy": "",
  244. "service_modules": []
  245. }
  246. ]
  247. }
  248. ],
  249. "notify_ctls": [ // 通知配置信息列表
  250. {
  251. "enabled": true,
  252. "webhook_type": "wechat",
  253. "weChat_webHook": "xxx",
  254. "notify_type": [
  255. "created",
  256. "failed"
  257. ]
  258. }
  259. ],
  260. "share_storages": [], // 共享卷信息
  261. "concurrency_limit": 1 // 并发执行数量
  262. }

获取自定义工作流任务列表

请求

  1. GET /openapi/workflows/custom/:workflowKey/tasks?projectKey=<项目标识>

query 参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识
pageNumint分页-当前页数1
pageSizeint分页-单页展示条目50

路径参数说明

参数名类型描述是否必须默认值
workflowKeystring工作流标识

返回说明

参数名类型描述
totalint工作流任务总数
workflow_tasks[]workflow_task工作流任务列表

workflow_task

参数名类型描述
workflow_keystring工作流标识
workflow_namestring工作流名称
project_keystring项目标识
task_idint工作流任务ID
task_creatorstring工作流任务执行者
create_timeint工作流任务创建时间
start_timeint工作流任务开始时间
end_timeint工作流任务结束时间
statusstring任务状态包括:created(创建中)、running(运行中)、passed(通过)、failed(失败)、timeout(超时)、cancelled(取消)

正常返回

  1. {
  2. "total": 15,
  3. "workflow_tasks": [
  4. {
  5. "workflow_key": "build-deploy",
  6. "workflow_name": "build-deploy",
  7. "project_key": "lilian-test",
  8. "task_id": 15,
  9. "create_time": 1688543613,
  10. "task_creator": "webhook",
  11. "start_time": 1688543615,
  12. "end_time": 1688543636,
  13. "status": "passed"
  14. }
  15. ]
  16. }

异常返回

  1. {
  2. "code": 400,
  3. "description": "workflow name is required",
  4. "extra": {},
  5. "message": "Bad Request",
  6. "type": "error"
  7. }

获取自定义工作流任务详情

  1. GET /openapi/workflows/custom/task?taskId=<工作流任务ID>&workflowKey=<工作流标识>

Query

参数名类型描述默认值是否必须
taskIdint工作流任务 ID
workflowKeystring工作流标识

正常返回

点击查看

  1. {
  2. "task_id": 24, # 自定义工作流任务序号 ID
  3. "workflow_key": "build-images", # 自定义工作流标识
  4. "params": [ # 自定义工作流变量
  5. {
  6. "name": "USERNAME",
  7. "description": "",
  8. "type": "string",
  9. "value": "zadig",
  10. "default": "",
  11. "is_credential": false
  12. }
  13. ],
  14. "status": "running", # 自定义工作流任务状态
  15. "task_creator": "admin", # 自定义工作流任务触发者
  16. "create_time": 1664161285, # 工作流任务创建时间,Unix 时间戳格式
  17. "start_time": 1664161286, # 工作流任务开始执行时间,Unix 时间戳格式
  18. "end_time": 1664172997, # 工作流任务执行结束时间,Unix 时间戳格式
  19. "stages": [ # 工作流任务包含的所有阶段详情
  20. {
  21. "name": "构建", # 阶段名称
  22. "status": "passed", # 阶段状态
  23. "start_time": 1664161286, # 阶段执行开始时间,Unix 时间戳格式
  24. "end_time": 1664172974, # 阶段执行结束时间,Unix 时间戳格式
  25. "jobs": [ # 阶段中包含的所有任务详情
  26. {
  27. "name": "a-myapp-1-build-myapps",
  28. "type": "zadig-build", # 内置构建任务
  29. "status": "passed", # 任务状态
  30. "start_time": 1664172967, # 任务执行开始时间,Unix 时间戳格式
  31. "end_time": 1664172974, # 任务执行结束时间,Unix 时间戳格式
  32. "spec": { # 构建任务执行详细信息(包括代码信息、镜像信息、服务信息、服务组件信息、构建变量信息)
  33. "repos": [ # 代码信息
  34. {
  35. "source": "gitee",
  36. "repo_owner": "kr-test-dev",
  37. "repo_namespace": "kr-test-dev",
  38. "repo_name": "zadig",
  39. "remote_name": "origin",
  40. "branch": "main",
  41. "commit_id": "a13120997b95d8b63f2b5b29c700f89d38a5de54",
  42. "commit_message": "update pkg/microservice/warpdrive/config/const.go.\n\nSigned-off-by: grandy <10196377+grandy@user.noreply.gitee.com>",
  43. "address": "https://gitee.com",
  44. "author_name": "grandy"
  45. }
  46. ],
  47. "image": "koderover.tencentcloudcr.com/koderover-demo/myapp-1:20220926141606-26-main", # 镜像信息
  48. "service_name": "a", # 服务名称
  49. "service_module": "myapp-1", # 服务组件名称
  50. "envs": [ # 构建变量信息
  51. {
  52. "key": "username",
  53. "value": "admin",
  54. "type": "string",
  55. "is_credential": false
  56. },
  57. {
  58. "key": "password",
  59. "value": "zadig",
  60. "type": "string",
  61. "is_credential": true
  62. },
  63. {
  64. "key": "version",
  65. "value": "1",
  66. "type": "string",
  67. "is_credential": false
  68. }
  69. ]
  70. }
  71. }
  72. ]
  73. },
  74. {
  75. "name": "部署",
  76. "status": "passed",
  77. "start_time": 1664172974,
  78. "end_time": 1664172990,
  79. "approval": { # 审批信息
  80. "enabled": true, # 需要审批
  81. "approve_users": [ # 审批人列表
  82. {
  83. "user_name": "admin",
  84. "reject_or_approve": "approve",
  85. "comment": "LGTM",
  86. "operation_time": 1664172985
  87. }
  88. ],
  89. "timeout": 120, # 审批超时时间,单位:分钟
  90. "needed_approvers": 1, # 需要满足的审批通过人数
  91. "description": "需审批通过方可部署", # 审批描述
  92. "reject_or_approve": "approve" # approve:通过;reject:拒绝
  93. },
  94. "jobs": [
  95. {
  96. "name": "a-myapp-1-deploy-myapps",
  97. "type": "zadig-deploy", # 内置部署任务
  98. "status": "passed",
  99. "start_time": 1664172986,
  100. "end_time": 1664172990,
  101. "spec": { # 部署任务的详细信息
  102. "env": "dev",
  103. "skip_check_run_status": false, # 是否关闭服务状态检测
  104. "service_and_images": [ # 部署的服务、服务组件、镜像信息
  105. {
  106. "service_name": "a",
  107. "service_module": "myapp-1",
  108. "image": "koderover.tencentcloudcr.com/koderover-demo/myapp-1:20220926141606-26-main"
  109. }
  110. ]
  111. }
  112. }
  113. ]
  114. },
  115. {
  116. "name": "通用任务",
  117. "status": "passed",
  118. "start_time": 1664172990,
  119. "end_time": 1664172993,
  120. "jobs": [
  121. {
  122. "name": "echo-hello",
  123. "type": "freestyle", # 通用任务
  124. "status": "passed",
  125. "start_time": 1664172990,
  126. "end_time": 1664172993,
  127. "spec": { # 通用任务执行详细信息
  128. "repos": [
  129. {
  130. "source": "gitee",
  131. "repo_owner": "kr-test-dev",
  132. "repo_namespace": "kr-test-dev",
  133. "repo_name": "demo-test",
  134. "remote_name": "origin",
  135. "branch": "master",
  136. "commit_id": "2000aba9195bfce73b0a676e48c0ebfe2f59a4a9",
  137. "commit_message": "update org-debug.txt.\n\nSigned-off-by: grandy <10196377+grandy@user.noreply.gitee.com>",
  138. "address": "https://gitee.com",
  139. "author_name": "grandy"
  140. }
  141. ],
  142. "image": "",
  143. "service_name": "",
  144. "service_module": "",
  145. "envs": [
  146. {
  147. "key": "myName",
  148. "value": "zadig",
  149. "type": "string",
  150. "is_credential": false
  151. }
  152. ]
  153. }
  154. }
  155. ]
  156. },
  157. {
  158. "name": "自定义任务",
  159. "status": "passed",
  160. "start_time": 1664172993,
  161. "end_time": 1664172997,
  162. "jobs": [
  163. {
  164. "name": "say-hi",
  165. "type": "plugin", # 自定义任务
  166. "status": "passed",
  167. "start_time": 1664172993,
  168. "end_time": 1664172997,
  169. "error": "",
  170. "spec": {
  171. "name": "输出 Hello 问候信息",
  172. "is_offical": false,
  173. "description": "问候指定用户",
  174. "repo_url": "",
  175. "version": "v0.0.1",
  176. "image": "koderover.tencentcloudcr.com/koderover-public/greeting-bot:20220923-amd64",
  177. "args": [],
  178. "cmds": [],
  179. "envs": [
  180. {
  181. "name": "WHO_AM_I",
  182. "value": "Zadig"
  183. },
  184. {
  185. "name": "WEATHER_STATUS",
  186. "value": "sunny"
  187. }
  188. ],
  189. "inputs": [
  190. {
  191. "name": "who_am_i",
  192. "description": "who am i",
  193. "type": "string",
  194. "value": "zadig",
  195. "default": "zadig",
  196. "is_credential": false
  197. },
  198. {
  199. "name": "weather_status",
  200. "description": "what's the weather like today",
  201. "type": "choice",
  202. "value": "sunny",
  203. "choice_否": [
  204. "sunny",
  205. "cloudy",
  206. "rainy"
  207. ],
  208. "default": "sunny",
  209. "is_credential": false
  210. }
  211. ],
  212. "outputs": []
  213. }
  214. }
  215. ]
  216. }
  217. ],
  218. "project_key": "simple-service-demo", # 项目标识
  219. }

异常返回

  1. # 指定的工作流任务不存在
  2. {
  3. "code": 500,
  4. "description": "mongo: no documents in result",
  5. "message": "Internal Error: "
  6. }

执行自定义工作流

注意事项

  1. 暂不支持通过 OpenAPI 触发自定义任务
  2. 暂不支持通过 OpenAPI 指定工作流全局变量

请求

  1. POST /openapi/workflows/custom/task

body 参数样例

点击查看

  1. {
  2. "project_key": "helm", // 项目标识
  3. "workflow_key": "test-openapi", // 工作流标识
  4. "inputs": [
  5. {
  6. "job_name": "build-myapps",
  7. "job_type": "zadig-build",
  8. "parameters": {
  9. "registry": "https://koderover.******.com/test",
  10. "service_list": [
  11. {
  12. "service_module": "aslan",
  13. "service_name": "zadig",
  14. "repo_info": [{
  15. "codehost_name": "koderover",
  16. "repo_namespace": "koderover",
  17. "repo_name": "zadig",
  18. "branch": "main"
  19. }]
  20. inputs: [{
  21. "key": "username",
  22. "value": "admin"
  23. },
  24. {
  25. "key": "password",
  26. "value": "Zadig"
  27. }]
  28. }
  29. ]
  30. }
  31. },
  32. {
  33. "job_name": "deploy-myapps",
  34. "job_type": "zadig-deploy",
  35. "parameters": {
  36. "env_name": "dev",
  37. "service_list": [
  38. {
  39. "service_name": "zadig",
  40. "service_module": "aslan",
  41. "image_name": "koderover.******.com/test/aslan:main"
  42. },
  43. {
  44. "service_name": "zadig",
  45. "service_module": "zadig-portal",
  46. "image_name": "koderover.******.com/test/zadig-portal:main"
  47. }
  48. ]
  49. }
  50. {
  51. "job_name": "jira-issue-update",
  52. "job_type": "freestyle",
  53. "parameters": {
  54. "kv": [
  55. {
  56. "key": "IssueID",
  57. "value": "ZAD-10126"
  58. },
  59. {
  60. "key": "FromStatus",
  61. "value": "Testing"
  62. },
  63. {
  64. "key": "TargetStatus",
  65. "value": "ToBeReleased"
  66. }
  67. ]
  68. }
  69. },
  70. {
  71. "job_name": "deploy-my-app",
  72. "job_type": "custom-deploy",
  73. "parameters": {
  74. "target_list": [
  75. {
  76. "workload_type": "Deployment",
  77. "workload_name": "service2",
  78. "container_name": "service2",
  79. "image_name": "koderover.***.com/test/service2:0505"
  80. }
  81. ]
  82. }
  83. }
  84. ]
  85. }

body 参数说明

参数名类型描述默认值是否必须
project_keystring项目标识
workflow_keystring自定义工作流标识
inputs[]Input执行工作流的具体参数

Input 参数说明

下面将分开介绍内置构建任务、部署任务、Kubernetes 部署任务、通用任务的触发参数。

构建任务

  1. {
  2. "job_name": "build-myapps", # 构建任务名称
  3. "job_type": "zadig-build", # 构建任务类型,指定为 zadig-build
  4. "parameters": {
  5. "registry": "https://koderover.******.com/test", # 镜像仓库信息
  6. "service_list": [ # 要构建的服务信息
  7. {
  8. "service_module": "aslan", # 服务组件名称
  9. "service_name": "zadig", # 服务名称
  10. "repo_info": [{ # 构建该服务组件的代码库信息
  11. "codehost_name": "koderover", # 代码源标识
  12. "repo_namespace": "koderover", # 代码库组织名/用户名
  13. "repo_name": "zadig", # 代码库名称
  14. "branch": "main" # 代码库分支
  15. }]
  16. inputs: [{ # 构建变量信息,若设置为固定值或全局变量,则无需指定
  17. "key": "username",
  18. "value": "admin"
  19. },
  20. {
  21. "key": "password",
  22. "value": "Zadig"
  23. }]
  24. },
  25. {
  26. "service_module": "zadig-portal",
  27. "service_name": "zadig",
  28. "repo_info": [{
  29. "codehost_name": "koderover",
  30. "repo_namespace": "koderover",
  31. "repo_name": "zadig-portal",
  32. "branch": "main"
  33. }]
  34. }
  35. ]
  36. }
  37. }

部署任务

  1. {
  2. "job_name": "deploy-myapps", # 部署任务名称
  3. "job_type": "zadig-deploy", # 部署任务类型,指定为 zadig-deploy
  4. "parameters": { # 部署参数
  5. "env_name": "dev", # 待部署环境信息,若设置为固定值或全局变量,则无需配置该字段
  6. "service_list": [ # 待部署服务信息,若设置为其他任务输出,则无需配置该字段
  7. {
  8. "service_name": "zadig", # 待部署服务名称
  9. "service_module": "aslan", # 待部署服务组件名称
  10. "image_name": "koderover.***.com/test/aslan:main" # 待部署服务组件的镜像
  11. },
  12. {
  13. "service_name": "zadig",
  14. "service_module": "zadig-portal",
  15. "image_name": "koderover.***.com/test/zadig-portal:main"
  16. }
  17. ]
  18. }

Kubernetes 部署任务

  1. {
  2. "job_name": "deploy-my-app", # Kubernetes 部署任务名称
  3. "job_type": "custom-deploy", # Kubernetes 部署任务类型,指定为 custom-deploy
  4. "parameters": {
  5. "target_list": [ # 待部署容器信息,若设置为固定值,则无需指定
  6. {
  7. "workload_type": "Deployment", # 待部署容器应用的类型,支持 Deployment 以及 StatefulSet
  8. "workload_name": "service2", # 待部署容器应用的名称
  9. "container_name": "service2", # 待部署容器应用的 container 名称
  10. "image_name": "koderover.***.com/test/service2:0505" # 待部署容器的镜像信息
  11. }
  12. ]
  13. }
  14. }

通用任务

  1. {
  2. "job_name": "jira-issue-update", # 通用任务名称
  3. "job_type": "freestyle", # 通用任务类型,指定为 freestyle
  4. "parameters": { # 通用任务中的参数和值,若设置为固定值或全局变量,则无需指定
  5. "kv": [
  6. {
  7. "key": "IssueID",
  8. "value": "ZAD-10126"
  9. },
  10. {
  11. "key": "FromStatus",
  12. "value": "Testing"
  13. },
  14. {
  15. "key": "TargetStatus",
  16. "value": "ToBeReleased"
  17. }
  18. ],
  19. "repo_info": [ # 通用任务中的代码库信息
  20. {
  21. "codehost_name": "koderover", # 代码源标识
  22. "repo_namespace": "koderover", # 代码库组织名/用户名
  23. "repo_name": "zadig", # 代码库名称
  24. "branch": "task-mgr" # 代码库分支
  25. }
  26. ]
  27. }
  28. }

测试任务

  1. {
  2. "job_name": "test-myapps", # 测试任务名称
  3. "job_type": "zadig-test", # 构建任务类型,指定为 zadig-test
  4. "parameters": {
  5. "testing_list": [ # 要测试的任务信息
  6. {
  7. "testing_name": "unit-test", # 测试任务名称
  8. "repo_info": [{ # 测试任务的代码库信息
  9. "codehost_name": "koderover", # 代码源标识
  10. "repo_namespace": "koderover", # 代码库组织名/用户名
  11. "repo_name": "zadig", # 代码库名称
  12. "branch": "main" # 代码库分支
  13. }]
  14. inputs: [{ # 测试变量信息,若设置为固定值或全局变量,则无需指定
  15. "key": "username",
  16. "value": "admin"
  17. },
  18. {
  19. "key": "password",
  20. "value": "Zadig"
  21. }]
  22. },
  23. {
  24. "testing_name": "integration-test",
  25. "repo_info": [{
  26. "codehost_name": "koderover",
  27. "repo_namespace": "koderover",
  28. "repo_name": "zadig-portal",
  29. "branch": "main"
  30. }]
  31. }
  32. ]
  33. }
  34. }

代码扫描任务

  1. {
  2. "job_name": "scan-myapps", # 代码扫描任务名称
  3. "job_type": "zadig-scanning", # 构建任务类型,指定为 zadig-scanning
  4. "parameters": {
  5. "scanning_list": [ # 代码扫描的任务信息
  6. {
  7. "scanning_name": "scan", # 代码扫描任务名称
  8. "repo_info": [{ # 代码扫描任务的代码库信息
  9. "codehost_name": "koderover", # 代码源标识
  10. "repo_namespace": "koderover", # 代码库组织名/用户名
  11. "repo_name": "zadig", # 代码库名称
  12. "branch": "main" # 代码库分支
  13. }]
  14. },
  15. {
  16. "scanning_name": "scan-1",
  17. "repo_info": [{
  18. "codehost_name": "koderover",
  19. "repo_namespace": "koderover",
  20. "repo_name": "zadig-portal",
  21. "branch": "main"
  22. }]
  23. }
  24. ]
  25. }
  26. }

正常返回

  1. {
  2. "project_name": "simple-service-demo", # 项目标识
  3. "workflow_name": "openapi-test", # 自定义工作流名称
  4. "task_id": 20 # 自定义工作流任务执行的序号 ID
  5. }

取消自定义工作流任务

请求

  1. DELETE /openapi/workflows/custom/task?task_id=<task_id>&workflowKey=<工作流标识>

Query

参数名类型描述默认值是否必须
task_idint自定义工作流任务 ID
workflowKeystring自定义工作流标识

正常返回

  1. {
  2. "message": "success"
  3. }

异常返回

  1. # 指定的工作流任务已成功运行完毕
  2. {
  3. "code": 6163,
  4. "description": "task: build-images:20 is passed, cannot cancel",
  5. "extra": {},
  6. "message": "取消工作流任务失败",
  7. "type": "error"
  8. }
  9. # 指定的工作流或者任务不存在
  10. {
  11. "code": 6163,
  12. "description": "mongo: no documents in result",
  13. "extra": {},
  14. "message": "取消工作流任务失败",
  15. "type": "error"
  16. }

重试自定义工作流任务

请求

  1. POST /openapi/workflows/custom/:workflowKey/task/:taskID?projectKey=<项目标识>

query 参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识

路径参数说明

参数名类型描述是否必须默认值
workflowKeystring工作流标识
taskIDint工作流任务ID

正常返回

  1. {
  2. "message": "success"
  3. }

异常返回

  1. {
  2. "code": 6161,
  3. "description": "mongo: no documents in result",
  4. "extra": {},
  5. "message": "获取工作流任务失败",
  6. "type": "error"
  7. }

审批自定义工作流

提示

适用于 Zadig 审批。

请求

  1. POST /openapi/workflows/custom/task/approve

body 参数说明

参数名类型描述默认值是否必须
task_idint自定义工作流任务 ID
workflow_keystring自定义工作流标识
stage_namestring自定义工作流待审批的阶段名称
approvebool是否审批通过false
commentstring审批信息

body 参数示例

  1. {
  2. "task_id": 2,
  3. "workflow_key": "infra-dev-workflow",
  4. "stage_name": "deploy",
  5. "approve": true,
  6. "comment": "LGTM"
  7. }

正常返回

  1. {
  2. "message": "success"
  3. }

异常返回

  1. # 指定参数的阶段不需要审批
  2. {
  3. "code": 6169,
  4. "description": "workflow build-images ID 23 stage deploy-myapps do not need approve",
  5. "extra": {},
  6. "message": "批准工作流任务失败",
  7. "type": "error"
  8. }

创建自定义工作流

请求

  1. POST /api/aslan/workflow/v4

body 参数说明

提示

该接口的参数相对复杂,自己组装比较费力。推荐先在页面中创建自定义工作流 -> 在配置页面点击 YAML -> 复制 YAML 内容后借助在线转换工具 工作流 - 图1 (opens new window)来快速获得参数。

工作流 - 图2

参数名类型描述默认值是否必须
namestring自定义工作流标识
display_namestring自定义工作流名称
projectstring项目标识
descriptionstring自定义工作流描述信息
concurrency_limitint工作流任务并发数,-1 表示无限制,0 表示不可执行0
stages[]Stage阶段配置

Stage 参数说明

参数名描述类型必填
name阶段名称string
parallel是否开启并发执行bool
approval人工审批配置[]Approval
jobs任务配置[]interface{}

Approval 参数说明

参数名描述类型必填
enabled是否开启人工审批bool
type审批方式,可选值如下:
native(即:Zadig 审批)
lark(即:飞书审批)
stringenabled = true 时必填
native_approvalZadig 审批配置[]NativeApprovaltype = native 时必填
lark_approval飞书审批配置[]LarkApprovaltype = lark 时必填

NativeApproval 参数说明

参数名描述类型必填
approve_users审批人清单[]ApproveUser
timeout超时时间,单位分钟int
needed_approvers需要审批的人数int

ApproveUser 参数说明

参数名描述类型必填
user_name审批人的账号名称string
user_id审批人的账号 IDstring

LarkApproval 参数说明

参数名描述类型必填
approve_users审批人清单[]LarkApproveUser
timeout超时时间,单位分钟int

LarkApproveUser 参数说明

参数名描述类型必填
id审批人的账号 IDstring
name审批人的账号名称string

body 参数示例

以下 body 示例中包含 构建 -> 部署 -> 测试 -> 自定义任务四个阶段:

点击查看

  1. {
  2. "name": "workflow-demo",
  3. "display_name": "workflow-demo",
  4. "project": "demo",
  5. "description": "workflow-demo description",
  6. "concurrency_limit": 5,
  7. "stages": [
  8. {
  9. "name": "构建",
  10. "parallel": true,
  11. "jobs": [
  12. {
  13. "name": "build",
  14. "type": "zadig-build",
  15. "run_policy": "",
  16. "spec": {
  17. "docker_registry_id": "62c**********",
  18. "service_and_builds": [
  19. {
  20. "service_name": "service1",
  21. "service_module": "service1",
  22. "image_name": "nginx",
  23. "value": "service1/service1",
  24. "build_name": "build-demo"
  25. }
  26. ]
  27. }
  28. }
  29. ]
  30. },
  31. {
  32. "name": "部署",
  33. "parallel": true,
  34. "approval": {
  35. "enabled": true,
  36. "type": "native",
  37. "native_approval": {
  38. "approve_users": [
  39. {
  40. "user_name": "admin",
  41. "user_id": "9792310b-**********"
  42. },
  43. {
  44. "user_name": "sre-admin",
  45. "user_id": "9837370s-**********"
  46. }
  47. ],
  48. "timeout": 5,
  49. "needed_approvers": 1
  50. }
  51. },
  52. "jobs": [
  53. {
  54. "name": "deploy",
  55. "type": "zadig-deploy",
  56. "spec": {
  57. "env": "dev",
  58. "production": false,
  59. "deploy_contents": [
  60. "image"
  61. ],
  62. "skip_check_run_status": false,
  63. "source": "fromjob",
  64. "job_name": "build",
  65. "service_and_images": [
  66. {
  67. "service_name": "service1",
  68. "service_module": "service1",
  69. "value": "service1/service1"
  70. }
  71. ]
  72. }
  73. }
  74. ]
  75. },
  76. {
  77. "name": "测试",
  78. "parallel": true,
  79. "jobs": [
  80. {
  81. "name": "test",
  82. "type": "zadig-test",
  83. "spec": {
  84. "test_type": "service_test",
  85. "source": "fromjob",
  86. "job_name": "build",
  87. "service_and_tests": [
  88. {
  89. "service_name": "service1",
  90. "service_module": "service1",
  91. "name": "smoke-test",
  92. "project_name": "voting-app"
  93. }
  94. ]
  95. }
  96. }
  97. ]
  98. },
  99. {
  100. "name": "分发",
  101. "parallel": true,
  102. "jobs": [
  103. {
  104. "name": "common",
  105. "type": "freestyle",
  106. "run_policy": "",
  107. "spec": {
  108. "properties": {
  109. "timeout": 60,
  110. "res_req": "low",
  111. "res_req_spec": {
  112. "cpu_limit": 1000,
  113. "memory_limit": 512
  114. },
  115. "cluster_id": "",
  116. "build_os": "focal",
  117. "image_id": "630xxxxxxxxxxxx",
  118. "image_from": "koderover",
  119. "envs": [
  120. {
  121. "key": "key1",
  122. "value": "val1",
  123. "type": "string",
  124. "is_credential": false
  125. }
  126. ],
  127. "cache_enable": true,
  128. "cache_dir_type": "workspace",
  129. "cache_user_dir": ""
  130. },
  131. "steps": [
  132. {
  133. "name": "tools",
  134. "type": "tools",
  135. "spec": {
  136. "installs": [
  137. {
  138. "name": "go",
  139. "version": "1.19.3",
  140. "id": "go1.19.3"
  141. }
  142. ]
  143. }
  144. },
  145. {
  146. "name": "git",
  147. "type": "git",
  148. "spec": {
  149. "repos": [
  150. {
  151. "codehost_id": 23,
  152. "repo_owner": "owner1",
  153. "repo_name": "hello",
  154. "source": "GitHub",
  155. "branch": "main",
  156. "checkout_path": "",
  157. "remote_name": "origin",
  158. "submodules": false,
  159. "hidden": false,
  160. "repo_namespace": "owner1"
  161. }
  162. ]
  163. }
  164. },
  165. {
  166. "name": "shell",
  167. "type": "shell",
  168. "spec": {
  169. "script": "#!/bin/bash\nset -e\necho hello"
  170. }
  171. }
  172. ]
  173. }
  174. }
  175. ]
  176. },
  177. {
  178. "name": "镜像分发",
  179. "parallel": true,
  180. "jobs": [
  181. {
  182. "name": "image-release",
  183. "type": "zadig-distribute-image",
  184. "run_policy": "",
  185. "isCreate": true,
  186. "spec": {
  187. "source": "fromjob",
  188. "job_name": "build",
  189. "source_registry_id": "",
  190. "target_registry_id": "630xxxxxxxxxxxx",
  191. "targets": [
  192. {
  193. "service_name": "n-1",
  194. "service_module": "nginx-latest",
  195. "image_name": "nginx",
  196. "value": "n-1/nginx-latest"
  197. }
  198. ],
  199. "timeout": 10,
  200. "cluster_id": "",
  201. "params": []
  202. }
  203. }
  204. ]
  205. }
  206. ]
  207. }

更新自定义工作流

请求

  1. PUT /api/aslan/workflow/v4/:name?projectName=<project_name>

query 参数说明

参数名类型描述是否必须默认值
projectNamestring项目标识

路径参数说明

参数名类型描述是否必须默认值
namestring工作流名称

body 参数说明

参考创建自定义工作流参数

删除自定义工作流

请求

  1. DELETE /openapi/workflows/custom?workflowKey=<工作流标识>&projectKey=<项目标识>

query 参数说明

参数名类型描述默认值是否必须
workflowKeystring工作流标识
projectKeystring项目标识

正常返回

  1. {
  2. "message": "success"
  3. }

工作流视图

获取工作流视图列表

请求

  1. GET /openapi/workflows/view?projectKey=<项目标识>

query 参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识

返回说明

参数名说明类型
name视图名称string
project_key项目标识string
update_time更新时间int
update_by更新者string
workflows工作流列表[]workflow

workflow

参数名说明类型
workflow_key工作流标识string
workflow_type工作流类型,有以下两种类型:
product:产品工作流
custom:自定义工作流
string

正常返回

点击查看

  1. [
  2. {
  3. "name": "test-view",
  4. "project_key": "lilian-test",
  5. "workflows": [
  6. {
  7. "workflow_key": "xiaxianfuwu",
  8. "workflow_type": "custom",
  9. }
  10. ],
  11. "update_time": 1689329334,
  12. "update_by": "admin"
  13. }
  14. ]

创建工作流视图

请求

  1. POST /openapi/workflows/view

body 参数说明

参数名说明类型必填
project_key项目标识string
name工作流视图名称string
workflow_list工作流列表[]Workflow

Workflow 参数说明

参数名说明类型必填
workflow_key工作流标识string
workflow_type工作流类型,有以下两种类型:
product:产品工作流
custom:自定义工作流
string

body 参数示例

点击查看

  1. {
  2. "project_key": "demo",
  3. "name": "view-demo",
  4. "workflow_list": [
  5. {
  6. "workflow_key": "dev",
  7. "workflow_type": "custom"
  8. },
  9. {
  10. "workflow_key": "nacos-config-update",
  11. "workflow_type": "custom"
  12. }
  13. ]
  14. }

正常返回

  1. {
  2. "message": "success"
  3. }

编辑工作流视图

请求

  1. PUT /openapi/workflows/view/:viewName?projectKey=<项目标识>

query 参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识

路径参数说明

参数名类型描述是否必须默认值
viewNamestring视图名称

body 参数说明

参数名说明类型必填默认值
workflow_list工作流列表[]Workflow

workflow

参数名说明类型必填默认值
workflow_key工作流标识string
workflow_type工作流类型,有以下两种类型:
product:产品工作流
custom:自定义工作流
string
enabledtrue:将工作流加入视图
false:将工作流从视图中删除
bool

body参数示例

点击查看

  1. {
  2. "workflow_list":[
  3. {
  4. "workflow_key":"build-deploy",
  5. "workflow_type":"custom",
  6. "enabled":true
  7. }
  8. ]
  9. }

正常返回

  1. {
  2. "message": "success"
  3. }

删除工作流视图

请求

  1. DELETE /openapi/workflows/view/:viewName?projectKey=<项目标识>

query 参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识

路径参数说明

参数名类型描述是否必须默认值
viewNamestring视图名称

正常返回

  1. {
  2. "message": "success"
  3. }

异常返回

  1. {
  2. "code": 6894,
  3. "description": "find workflow view error: mongo: no documents in result",
  4. "extra": {},
  5. "message": "删除视图失败",
  6. "type": "error"
  7. }

产品工作流 适用 2.1.0 及以下版本

通过 commitId 获取工作流任务状态

注意事项

  • 目前仅支持 GitLab 的 commitId 查询
  • 支持完整的 commitId 或者输入 commitId 前 8 位查询

请求

  1. GET /api/directory/workflowTask?commitId=<commitId>

Query

参数名类型描述默认值是否必须
commitIdstringcommitId

正常返回

  1. [
  2. {
  3. "task_id": 49,
  4. "create_time": 1639466317,
  5. "start_time": 1639466318,
  6. "end_time": 1639466354,
  7. "status": "passed",
  8. "url": "http://my.zadig.com/v1/projects/detail/proxy/pipelines/multi/workflow-demo/49"
  9. }
  10. ]

返回说明

参数名类型描述
task_idint64任务 id
urlstring任务具体 url
statusstring任务状态
create_timeint64Unix 时间戳格式的任务创建时间
start_timeint64Unix 时间戳格式的任务开始时间
end_timeint64Unix 时间戳格式的任务结束时间

任务状态包括:created(创建中)/running(运行中)/passed(通过)/failed(失败)/timeout(超时)/cancelled(取消)

错误码对应列表

  1. {
  2. "resultCode":401,"errorMsg":"auth failed!",
  3. "resultCode":400,"errorMsg":"param is illegal!"
  4. }

通过任务 ID 获取工作流任务状态

请求

  1. GET /openapi/workflows/product/:workflowKey/task/:taskID?projectKey=<项目标识>

Query参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识

路径参数说明

参数名类型描述是否必须默认值
workflowKeystring工作流标识
taskIDint任务 id

返回说明

参数名类型描述
project_keystring项目标识
workflow_keystring工作流标识
workflow_namestring工作流名称
task_idint工作流任务ID
task_creatorstring工作流任务执行者
create_timeint工作流任务创建时间
start_timeint工作流任务开始时间
end_timeint工作流任务结束时间
statusstring任务状态包括:created(创建中)、running(运行中)、passed(通过)、failed(失败)、timeout(超时)、cancelled(取消)

正常返回

  1. {
  2. "workflow_key": "patrick-yaml-01-ops-workflow",
  3. "workflow_name": "patrick-yaml-01-ops-workflow",
  4. "project_key": "patrick-yaml-01",
  5. "task_id": 7,
  6. "create_time": 1688622655,
  7. "task_creator": "admin",
  8. "start_time": 1688622658,
  9. "end_time": 1688622670,
  10. "status": "passed",
  11. }

异常返回

  1. "code": 6161,
  2. "description": "",
  3. "extra": {},
  4. "message": "获取工作流任务失败",
  5. "type": "error"
  6. }

获取工作流任务列表

请求

  1. GET /openapi/workflows/product/:workflowKey/tasks?projectKey=<项目标识>&pageNum=<当前页>&pageSize=<单页显示条数>

query 参数说明

参数名类型描述是否必须默认值
projectKeystring项目标识
pageNumint分页参数-当前页数1
pageSizeint分页参数-当前页展示条数50

路径参数说明

参数名类型描述是否必须默认值
workflowKeystring工作流标识

返回说明

参数名类型描述
project_keystring项目标识
workflow_keystring工作流标识
task_idint工作流任务ID
task_creatorstring工作流任务执行者
create_timeint工作流任务创建时间
start_timeint工作流任务开始时间
end_timeint工作流任务结束时间
statusstring任务状态包括:created(创建中)、running(运行中)、passed(通过)、failed(失败)、timeout(超时)、cancelled(取消)

正常返回

  1. [
  2. {
  3. "workflow_key": "cosmos-build-1",
  4. "project_key": "cosmos-1",
  5. "task_id": 21,
  6. "create_time": 1689669590,
  7. "task_creator": "admin",
  8. "start_time": 1689669593,
  9. "end_time": 1689669615,
  10. "status": "cancelled"
  11. },
  12. ]

获取工作流任务详情

请求

  1. GET /api/directory/workflowTask/id/:id/pipelines/:pipelineName

路径参数说明

参数名类型描述默认值是否必须
idint任务 id
pipelineNamestring工作流标识

正常返回

点击查看

  1. {
  2. "workflow_name": "test-project-workflow-dev",
  3. "env_name": "dev",
  4. "targets": [
  5. {
  6. "name": "gss-1",
  7. "service_type": "helm",
  8. "build": {
  9. "repos": [
  10. {
  11. "repo_name": "hzx-test",
  12. "branch": "main",
  13. "pr": 0
  14. }
  15. ]
  16. }
  17. },
  18. {
  19. "name": "gss-2",
  20. "service_type": "helm",
  21. "build": {
  22. "repos": [
  23. {
  24. "repo_name": "hzx-test",
  25. "branch": "main",
  26. "pr": 0
  27. }
  28. ]
  29. }
  30. }
  31. ],
  32. "images": [
  33. {
  34. "image": "ccr.ccs.tencentyun.com/trial/go-sample-site:20211221120415-1-main",
  35. "service_name": "gss-1",
  36. "registry_repo" : "https://ccr.ccs.tencentyun.com/trial"
  37. },
  38. {
  39. "image": "ccr.ccs.tencentyun.com/trial/go-sample-site:20211221120415-1-main",
  40. "service_name": "gss-2",
  41. "registry_repo" : "https://ccr.ccs.tencentyun.com/trial"
  42. }
  43. ],
  44. "test_reports": [
  45. {
  46. "test_name": "test",
  47. "function_test_report": {
  48. "tests": 24,
  49. "successes": 24,
  50. "failures": 0,
  51. "skips": 0,
  52. "errors": 0,
  53. "detail_url": "/v1/projects/detail/test-project/pipelines/multi/testcase/test-project-workflow-dev/51/test/test-project-workflow-dev-51-test?is_workflow=1&service_name=test&test_type=function"
  54. }
  55. }
  56. ],
  57. "status": "timeout"
  58. }

返回说明

参数名类型描述
workflow_namestring工作流标识
env_namestring环境名称
statusstring任务状态
targets[]TargetArgs构建参数
images[]Image构建生成的镜像信息
test_reports[]TestReport测试报告信息
Image 参数说明
参数名类型描述
imagestring镜像地址
service_namestring服务名称
registry_repostring镜像仓库
TestReport 参数说明
参数名类型描述
test_namestring测试名称
function_test_reportFunctionTestReport测试报告概览
FunctionTestReport 参数说明
参数名类型描述
testsint测试用例数量
successesint成功数量
failuresint失败数量
skipsint跳过数量
errorsint错误数量
detail_urlstring测试报告详情 URL

异常返回

  1. {
  2. "code": 500,
  3. "description": "[400 BadRequest] {\"code\":6161,\"description\":\"\",\"extra\":{},\"message\":\"获取工作流任务失败\",\"type\":\"error\"}",
  4. "message": "Internal Error: "
  5. }

执行工作流

注意事项

  • 需要有执行工作流的权限;
  • 暂不支持更新环境变量;
  • 暂不支持高级选项,如工作流空间缓存和 Docker 缓存。

请求

  1. POST /openapi/workflows/product/task

body 参数样例

点击查看

  1. {
  2. "workflow_key": "my-workflow",
  3. "project_key": "my-workflow",
  4. "input": {
  5. "target_env": "dev",
  6. "build": {
  7. "enabled": true,
  8. "service_list": [
  9. {
  10. "service_module": "svc1",
  11. "service_name": "my_service",
  12. "repo_info": [
  13. {
  14. "codehost_name": "my_codehost",
  15. "repo_namespace": "my_namespace",
  16. "repo_name": "my_repo",
  17. "branch": "main"
  18. }
  19. ],
  20. "inputs": [
  21. {
  22. "key": "mykey",
  23. "value": "myvalue"
  24. }
  25. ]
  26. }
  27. ]
  28. },
  29. "deploy": {
  30. "enabled": true,
  31. "source": "zadig",
  32. "service_list": [
  33. {
  34. "service_module": "li",
  35. "service_name": "li",
  36. "image": "xxxxx:aaaaaa"
  37. }
  38. ]
  39. }
  40. }
  41. }

body 参数说明

参数名类型描述默认值是否必须
workflow_keystring工作流标识
project_keystring项目标识
inputWorkflowInput执行工作流参数
input 参数说明
参数名类型描述默认值是否必须
target_envstring目标环境名称
buildBuildArgs构建参数
deployDeployArgs部署参数
BuildArgs 参数说明
参数名类型描述默认值是否必须
enabledbool是否启用构建
service_list[]BuildServiceInfo构建服务所需信息
BuildServiceInfo 参数说明
参数名类型描述默认值是否必须
service_modulestring服务组件名称
service_namestring服务名称
repo_info[]RepositoryInfo代码库信息
inputs[]UserInput构建变量
RepositoryInfo 参数说明
参数名类型描述默认值是否必须
codehost_namestring代码源标识
repo_namespacestring代码库所属命名空间(组织/个人)
repo_namestring代码库名称
branchstring分支
printpr ID0使用 pr 构建时必传
UserInput 参数说明
参数名类型描述默认值是否必须
keystring自定义变量的键
valuestring自定义变量的值
DeployArgs 参数说明
参数名类型描述默认值是否必须
enabledbool是否启用构建
sourcestring部署镜像来源如果使用 Zadig 构建则固定为 “zadig”
service_list[]DeployServiceInfo部署服务所需信息
DeployServiceInfo 参数说明
参数名类型描述默认值是否必须
service_modulestring服务组件名称
service_namestring服务名称
imagestring镜像信息使用 Zadig 构建时不填,否则必填

正常返回

  1. {
  2. "project_name": "test-project",
  3. "workflow_name": "test-project-workflow-dev",
  4. "task_id": 74
  5. }

异常返回

  1. {
  2. "code": 6540,
  3. "description": "workflow [hello-world-workflow-dev] 在项目 [hellow-world] 中已经存在!",
  4. "extra": {},
  5. "message": "新建或更新wokflow失败",
  6. "type": "error"
  7. }

取消工作流任务

注意事项

  • 需要有执行工作流的权限;

请求

  1. POST /api/directory/workflowTask/id/:id/pipelines/:pipelineName/cancel

路径参数说明

参数名类型描述默认值是否必须
idint任务 id
pipelineNamestring工作流标识

正常返回

  1. {"message":"success"}

异常返回

  1. {
  2. "code": 6163,
  3. "description": "mongo: no documents in result",
  4. "extra": {},
  5. "message": "取消工作流任务失败",
  6. "type": "error"
  7. }

重试工作流任务

注意事项

  • 需要有执行工作流的权限
  • 支持对状态是 failed(失败)/timeout(超时)/cancelled(取消) 的工作流任务进行重试

请求

  1. POST /api/directory/workflowTask/id/:id/pipelines/:pipelineName/restart

路径参数说明

参数名类型描述默认值是否必须
idint任务 id
pipelineNamestring工作流标识

正常返回

  1. {"message":"success"}

异常返回

  1. {
  2. "code": 6164,
  3. "description": "获取工作流任务失败",
  4. "extra": {},
  5. "message": "重试工作流任务失败",
  6. "type": "error"
  7. }

删除工作流

请求

  1. DELETE /openapi/workflows/product?workflowKey=<工作流标识>&projectKey=<项目标识>

query 参数说明

参数名类型描述默认值是否必须
workflowKeystring工作流标识
projectKeystring项目标识

正常返回

  1. {
  2. "message": "success"
  3. }