功能描述

通过流程模板创建任务

请求参数

通用参数

字段 类型 必选 描述
bk_app_code string 应用ID
bk_app_secret string 安全密钥(应用 TOKEN),可以通过 蓝鲸智云开发者中心 -> 点击应用ID -> 基本信息 获取
bk_token string 当前用户登录态,bk_token与bk_username必须一个有效,bk_token可以通过Cookie获取
bk_username string 当前用户用户名,应用免登录态验证白名单中的应用,用此字段指定当前用户

接口参数

字段 类型 必选 描述
bk_biz_id string 模板所属业务ID
template_id string 模板ID
template_source string 流程模板来源,business:默认值,业务流程,common:公共流程
name string 任务名称
flow_type string 任务流程类型,common: 常规流程,common_func:职能化流程
constants dict 任务全局参数,详细信息见下面说明
exclude_task_nodes_id list 跳过执行的节点ID列表
scope string bk_biz_id 检索的作用域。默认为 cmdb_biz,此时检索的是绑定的 CMDB 业务 ID 为 bk_biz_id 的项目;当值为 project 时则检索项目 ID 为 bk_biz_id 的项目

constants KEY

变量 KEY,${key} 格式

constants VALUE

变量值,value 的类型和从模板获取的全局变量中 value 类型保持一致

请求参数示例

  1. {
  2. "bk_app_code": "esb_test",
  3. "bk_app_secret": "xxx",
  4. "bk_token": "xxx",
  5. "name": "tasktest",
  6. "flow_type": "common",
  7. "constants": {
  8. "${content}": "echo 1",
  9. "${params}": "",
  10. "${script_timeout}": 20
  11. }
  12. }

返回结果示例

  1. {
  2. "result": true,
  3. "data": {
  4. "task_id": 10,
  5. "task_url": "http://bk_sops_host/taskflow/execute/3/?instance_id=15364",
  6. "pipeline_tree": {
  7. "activities": {
  8. "node9b5ae13799d63e179f0ce3088b62": {
  9. "outgoing": "line27bc7b4ccbcf37ddb9d1f6572a04",
  10. "incoming": "line490caa49d2a03e64829693281032",
  11. "name": "timing",
  12. "error_ignorable": false,
  13. "component": {
  14. "code": "sleep_timer",
  15. "data": {
  16. "bk_timing": {
  17. "hook": false,
  18. "value": "2"
  19. }
  20. }
  21. },
  22. "stage_name": "步骤1",
  23. "retryable": true,
  24. "skippable": true,
  25. "type": "ServiceActivity",
  26. "optional": false,
  27. "id": "node9b5ae13799d63e179f0ce3088b62",
  28. "loop": null
  29. },
  30. "node880ded556c6c3c269be3cedc64b6": {
  31. "outgoing": "line490caa49d2a03e64829693281032",
  32. "incoming": "lineb83161d6e0593ad68d9ec73a961b",
  33. "name": "暂停",
  34. "error_ignorable": false,
  35. "component": {
  36. "code": "pause_node",
  37. "data": {}
  38. },
  39. "stage_name": "步骤1",
  40. "retryable": true,
  41. "skippable": true,
  42. "type": "ServiceActivity",
  43. "optional": true,
  44. "id": "node880ded556c6c3c269be3cedc64b6",
  45. "loop": null
  46. }
  47. },
  48. "end_event": {
  49. "type": "EmptyEndEvent",
  50. "outgoing": "",
  51. "incoming": "line27bc7b4ccbcf37ddb9d1f6572a04",
  52. "id": "node5c48f37aa9f0351e8b43ab6a2295",
  53. "name": ""
  54. },
  55. "outputs": [],
  56. "flows": {
  57. "line490caa49d2a03e64829693281032": {
  58. "is_default": false,
  59. "source": "node880ded556c6c3c269be3cedc64b6",
  60. "id": "line490caa49d2a03e64829693281032",
  61. "target": "node9b5ae13799d63e179f0ce3088b62"
  62. },
  63. "lineb83161d6e0593ad68d9ec73a961b": {
  64. "is_default": false,
  65. "source": "noded383bc1d7387391f889c6bab18b8",
  66. "id": "lineb83161d6e0593ad68d9ec73a961b",
  67. "target": "node880ded556c6c3c269be3cedc64b6"
  68. },
  69. "line27bc7b4ccbcf37ddb9d1f6572a04": {
  70. "is_default": false,
  71. "source": "node9b5ae13799d63e179f0ce3088b62",
  72. "id": "line27bc7b4ccbcf37ddb9d1f6572a04",
  73. "target": "node5c48f37aa9f0351e8b43ab6a2295"
  74. }
  75. },
  76. "gateways": {},
  77. "line": [
  78. {
  79. "source": {
  80. "id": "node9b5ae13799d63e179f0ce3088b62",
  81. "arrow": "Right"
  82. },
  83. "target": {
  84. "id": "node5c48f37aa9f0351e8b43ab6a2295",
  85. "arrow": "Left"
  86. },
  87. "id": "line27bc7b4ccbcf37ddb9d1f6572a04"
  88. },
  89. {
  90. "source": {
  91. "id": "node880ded556c6c3c269be3cedc64b6",
  92. "arrow": "Right"
  93. },
  94. "target": {
  95. "id": "node9b5ae13799d63e179f0ce3088b62",
  96. "arrow": "Left"
  97. },
  98. "id": "line490caa49d2a03e64829693281032"
  99. },
  100. {
  101. "source": {
  102. "id": "noded383bc1d7387391f889c6bab18b8",
  103. "arrow": "Right"
  104. },
  105. "id": "lineb83161d6e0593ad68d9ec73a961b",
  106. "target": {
  107. "id": "node880ded556c6c3c269be3cedc64b6",
  108. "arrow": "Left"
  109. }
  110. }
  111. ],
  112. "start_event": {
  113. "type": "EmptyStartEvent",
  114. "outgoing": "lineb83161d6e0593ad68d9ec73a961b",
  115. "incoming": "",
  116. "id": "noded383bc1d7387391f889c6bab18b8",
  117. "name": ""
  118. },
  119. "id": "node7ef6970d06ad3bc092594cb5ec5f",
  120. "constants": {},
  121. "location": [
  122. {
  123. "stage_name": "步骤1",
  124. "name": "暂停",
  125. "y": 135,
  126. "x": 300,
  127. "type": "tasknode",
  128. "id": "node880ded556c6c3c269be3cedc64b6"
  129. },
  130. {
  131. "y": 150,
  132. "x": 1000,
  133. "type": "endpoint",
  134. "id": "node5c48f37aa9f0351e8b43ab6a2295"
  135. },
  136. {
  137. "stage_name": "步骤1",
  138. "name": "timing",
  139. "y": 135,
  140. "x": 595,
  141. "type": "tasknode",
  142. "id": "node9b5ae13799d63e179f0ce3088b62"
  143. },
  144. {
  145. "y": 150,
  146. "x": 80,
  147. "type": "startpoint",
  148. "id": "noded383bc1d7387391f889c6bab18b8"
  149. }
  150. ]
  151. }
  152. }
  153. }

返回结果参数说明

字段 类型 描述
result bool true/false 操作是否成功
data dict result=true 时成功数据,详细信息请见下面说明
message string result=false 时错误信息

data

字段 类型 描述
task_id int 任务实例ID
task_url str 任务实例链接
pipeline_tree dict 任务实例树

data.pipeline_tree

字段 类型 描述
start_event dict 开始节点信息
end_event dict 结束节点信息
activities dict 任务节点(标准插件和子流程)信息
gateways dict 网关节点(并行网关、分支网关和汇聚网关)信息
flows dict 顺序流(节点连线)信息
constants dict 全局变量信息,详情见下面
outputs list 模板输出信息,标记 constants 中的输出字段

data.pipeline_tree.constants KEY

全局变量 KEY,${key} 格式

data.pipeline_tree.constants VALUE

名称 类型 说明
key string 同 KEY
name string 变量名字
index int 变量在模板中的显示顺序
desc string 变量说明
source_type string 变量来源, 取值范围 custom: 自定义变量,component_inputs: 从标准插件输入参数勾选,component_outputs:从标准插件输出结果中勾选
custom_type string source_type=custom 时有效,自定义变量类型, 取值范围 input: 输入框,textarea: 文本框,datetime: 日期时间,int: 整数
source_tag string source_type=component_inputs/component_outputs 时有效,变量的来源标准插件
source_info dict source_type=component_inputs/component_outputs 时有效,变量的来源节点信息