基于模板快速创建流水线及流水线内任务(待下线)
功能介绍
基于模板快速创建流水线及流水线内任务
调试
您可以在API Explorer中调试该接口。
URI
POST /v3/templates/task
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
否 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
X-Language |
否 |
String |
语言类型 中文:zh-cn 英文:en-us,默认en-us |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
flow |
是 |
Map<String,Map<String,String>> |
编排flow详情,描述流水线内各阶段任务的串并行关系。map类型数据,key为阶段名字,默认第一阶段initial,最后阶段为final,其余名字以'state_数字'标识。value为该阶段内任务(以'Task_数字'标识)以及后续阶段的标识。本字段为描述流水线基础编排数据之一,建议可通过流水线真实界面基于模板创建接口中获取 |
states |
是 |
Map<String,TemplateState> |
编排State详情,map类型数据。本字段为描述流水线基础编排数据之一,建议可通过流水线真实界面基于模板创建接口中获取 |
workflow |
是 |
Workflow object |
参数详情 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
任务类型 |
name |
是 |
String |
任务名字 |
module_or_template_id |
是 |
String |
模板任务ID |
module_or_template_name |
是 |
String |
模板任务名字 |
display_name |
是 |
String |
任务在流水线页面展示名字 |
dsl_method |
是 |
String |
流水线可挂载任务类型 |
parameters |
是 |
Map<String,Object> |
任务参数,map类型数据 |
is_manual_execution |
是 |
Boolean |
是否手动执行 |
job_parameter_validate |
是 |
Boolean |
任务参数是否校验 |
is_show_codehub_url |
是 |
Boolean |
是否显示代码仓URL |
is_execute |
是 |
Boolean |
是否执行 |
job_id |
是 |
String |
执行任务ID |
job_name |
是 |
String |
执行任务名字 |
project_id |
是 |
String |
任务所属项目ID |
execution_mode |
是 |
String |
控制阶段下任务的串并行(type是task的execution_mode值为null,type是stage的execution_mode可选parallel(并行)或者serial(串行)) |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
parameter |
是 |
Array of PipelineParam objects |
任务类型,list类型数据 |
source |
是 |
Array of Source objects |
源码仓,list类型数据 |
name |
是 |
String |
流水线名字 |
project_id |
是 |
String |
项目ID |
project_name |
是 |
String |
项目名字 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
流水线参数名字 |
value |
是 |
String |
流水线参数值 |
description |
是 |
String |
流水线参数描述 |
param_type |
是 |
String |
流水线参数类型 |
is_static |
是 |
Boolean |
是否静态参数 |
is_default |
是 |
Boolean |
是否默认参数 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
codehub_name |
是 |
String |
源码仓名字 |
branches |
是 |
Array of strings |
触发分支 |
scm_type |
是 |
String |
源码仓来源 |
hook_flag |
是 |
Boolean |
是否开启触发执行流水线功能 |
branch |
是 |
String |
触发分支 |
git_url |
是 |
String |
源码仓ssh地址 |
codehub_id |
是 |
String |
源码仓ID |
web_url |
是 |
String |
源码仓首页url |
branch_list |
是 |
Array of strings |
分支列表 |
init_id |
是 |
String |
初始化ID |
disable |
是 |
Boolean |
是否废弃 |
响应参数
状态码: 201
参数 |
参数类型 |
描述 |
---|---|---|
task_id |
String |
实例ID |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_msg |
String |
错误信息 |
error_code |
String |
错误码 |
请求示例
POST https://{endpoint}/v3/templates/task { "flow" : { "initial" : { "state_3" : "always" }, "state_3" : { "state_4" : "always" }, "state_4" : { "state_5" : "always", "Task_1" : "always", "Task_2" : "always" }, "state_5" : { "final" : "always" } }, "states" : { "initial" : { "type" : "stage", "name" : "initial", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Initial", "dsl_method" : "initial", "parameters" : { "display" : "hidden" }, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" }, "state_3" : { "type" : "stage", "name" : "state_3", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Source", "dsl_method" : "source", "parameters" : null, "params" : null, "is_manual_execution" : false, "execution_mode" : "parallel" }, "Task_1" : { "type" : "task", "name" : "Task_1", "module_or_template_id" : "00012", "module_or_template_name" : "Maven", "display_name" : "Build_Task", "dsl_method" : "buildJob", "parameters" : { "__repository__" : { "repo_name" : "fdfdfdf", "url" : "git@codehub-cn-east-2.devcloud.huaweicloud.com:CloudPipelineTest-Copy00001/fdfdfdf.git" } }, "params" : null, "is_manual_execution" : false, "execution_mode" : null, "job_parameter_palidate" : true, "is_show_code_hub_url" : false, "is_execute" : true, "job_id" : "00012", "job_name" : "Maven", "project_id" : "4719b59466624abfbae0f83c3ce3a0dc" }, "Task_2" : { "type" : "task", "name" : "Task_2", "module_or_template_id" : "d7dffaefb6d94c63a09cf141668356c7", "module_or_template_name" : "codecheck_template", "display_name" : "Code_Check_Task", "dsl_method" : "codeCheck", "parameters" : { "language" : { "disable" : null, "name" : "Java", "display_name" : "Java", "id" : "782aade71ffb4ab780303555eb2e4825", "language" : "java" }, "codeBranch" : "master", "__repository__" : { "repo_name" : "fdfdfdf", "url" : "git@codehub-cn-east-2.devcloud.huaweicloud.com:CloudPipelineTest-Copy00001/fdfdfdf.git" } }, "params" : null, "is_manual_execution" : false, "execution_mode" : null, "job_parameter_palidate" : true, "is_show_code_hub_url" : false, "is_execute" : true, "job_id" : "d7dffaefb6d94c63a09cf141668356c7", "job_name" : "codecheck_template", "project_id" : "4719b59466624abfbae0f83c3ce3a0dc" }, "state_4" : { "type" : "stage", "name" : "state_4", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Build_and_Check", "dsl_method" : "build", "parameters" : null, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" }, "state_5" : { "type" : "stage", "name" : "state_5", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Release", "dsl_method" : "release", "parameters" : null, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" }, "final" : { "type" : "stage", "name" : "final", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Final", "dsl_method" : "final", "parameters" : null, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" } }, "workflow" : { "parameter" : [ { "name" : "serviceName", "value" : "pipeline-20201229165622", "description" : "this is a text type param", "paramtype" : "normalparam", "display_name" : null, "isStatic" : true, "isDefault" : true, "constraints" : null }, { "name" : "releaseVersion", "value" : "1.0.0", "description" : "this is a growth type param", "paramtype" : "growthparam", "display_name" : null, "isStatic" : false, "isDefault" : true, "constraints" : null } ], "source" : [ { "scmType" : "codehub", "codeHubName" : "fdfdfdf", "hookFlag" : false, "branches" : [ ], "defaultBranch" : "master", "branch" : "", "codeHubId" : "5224040", "gitUrl" : "git@codehub-cn-east-2.devcloud.huaweicloud.com:CloudPipelineTest-Copy00001/fdfdfdf.git", "webUrl" : "https://hd.devcloud.huaweicloud.com/codehub/project/bc97c4d99c7d4f98bb6cd104a77fddd6/codehub/140000127/home", "branchList" : [ "master" ] } ], "name" : "pipeline-123123", "description" : "", "project_id" : "bc97c4d99c7d4f98bb6cd104a77fddd6", "project_name" : "CloudPipelineTest-Copy" }, "changeInfo" : null }
响应示例
状态码: 201
OK
{ "task_id" : "eafaff0bf9094d3d8456d13dddf67b40" }
状态码
状态码 |
描述 |
---|---|
201 |
OK |
400 |
Bad request |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
错误码
请参见错误码。
