Quickly Creating a Pipeline and Jobs with a Template
Function
This API is used to quickly create a pipeline and jobs with a template.
Calling Method
For details, see Calling APIs.
URI
POST /v3/templates/task
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | No | String | User token. Obtain a token (the value of the X-Subject-Token response header) by calling the IAM API for . |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| flow | Yes | Map<String,Map<String,String>> | Definition: Orchestration flow details, which describe the serial and parallel jobs in each stage of a pipeline. The value is of the map type. key is the stage name. By default, the first stage is ** initial**, the last stage is final, and other stage are identified by state_number. value indicates jobs in a stage (identified by Task_ number), as well as the identifiers of subsequent stages to be executed. This field is one of the basic orchestration data of the pipeline. You are advised to obtain the data based on the template creation API on the pipeline page. Constraints: N/A Value range: N/A Default value: N/A |
| states | Yes | Map<String,TemplateState> | Definition: Orchestration state details. The value is of the map type. This field is one of the basic orchestration data of the pipeline. You are advised to obtain it from the template creation API on the pipeline page. Constraints: N/A Value range: N/A Default value: N/A |
| workflow | Yes | Workflow object | Definition: Parameter details. Constraints: N/A Value range: N/A Default value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | Yes | String | Job type. |
| name | Yes | String | Job name. |
| module_or_template_id | Yes | String | Template job ID. |
| module_or_template_name | Yes | String | Template job name. |
| display_name | Yes | String | Job name displayed on the pipeline page. |
| dsl_method | Yes | String | Types of jobs that can be mounted to a pipeline. |
| parameters | Yes | Map<String,Object> | Job parameter. The value is of the map type. |
| is_manual_execution | Yes | Boolean | Whether to manually execute the job. |
| job_parameter_validate | Yes | Boolean | Whether to verify job parameters. |
| is_show_codehub_url | Yes | Boolean | Whether to display the code repository URL. |
| is_execute | Yes | Boolean | Whether to execute |
| job_id | Yes | String | ID of the executed job. |
| job_name | Yes | String | Name of the executed job. |
| project_id | Yes | String | ID of the project to which the job belongs. |
| execution_mode | Yes | String | This parameter controls the execution mode of jobs in a stage. If type is task, the value of execution_mode is null. If type is stage, the value of execution_mode can be parallel or serial. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| parameter | Yes | Array of PipelineParam objects | Definition: Job type. The value is of the list type. Constraints: N/A Value range: N/A Default value: N/A |
| source | Yes | Array of Source objects | Definition: Source code repository. The value is of the list type. Constraints: N/A Value range: N/A Default value: N/A |
| name | Yes | String | Definition: Pipeline name. Constraints: N/A Value range: N/A Default value: N/A |
| project_id | Yes | String | Definition: Project ID. Constraints: N/A Value range: N/A Default value: N/A |
| project_name | Yes | String | Definition: Project name. Constraints: N/A Value range: N/A Default value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition: Pipeline parameter name. Constraints: N/A Value range: N/A Default value: N/A |
| value | Yes | String | Definition: Pipeline parameter value. Constraints: N/A Value range: N/A Default value: N/A |
| description | Yes | String | Definition: Pipeline parameter description. Constraints: N/A Value range: N/A Default value: N/A |
| param_type | Yes | String | Definition: Pipeline parameter type. Constraints: N/A Value range: N/A Default value: N/A |
| is_static | Yes | Boolean | Definition: Whether the parameter is static. Constraints: N/A Value range:
Default value: N/A |
| is_default | Yes | Boolean | Definition: Whether the parameter is a default parameter. Constraints: N/A Value range:
Default value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| codehub_name | Yes | String | Source code repository name. |
| branches | Yes | Array of strings | Triggered branch |
| scm_type | Yes | String | Source code repository type. |
| hook_flag | Yes | Boolean | Whether to enable the function of triggering pipeline execution. |
| branch | Yes | String | Triggered branch. |
| git_url | Yes | String | SSH address of the source code repository. |
| codehub_id | Yes | String | Source code repository ID. |
| web_url | Yes | String | URL of the source code repository homepage. |
| branch_list | Yes | Array of strings | Branch list. |
| init_id | Yes | String | Initialization ID. |
| disable | Yes | Boolean | Whether to discard |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| task_id | String | Definition: Instance ID. Value range: The value consists of 32 characters, including digits and letters. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_msg | String | Parameter description: Error message. Value range: N/A |
| error_code | String | Parameter description: Error code. Value range: N/A |
Example Requests
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@example.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@example.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@example.com:CloudPipelineTest-Copy00001/fdfdfdf.git",
"webUrl" : "https://example.com/codehub/project/bc97c4d99c7d4f98bb6cd104a77fddd6/codehub/140000127/home",
"branchList" : [ "master" ]
} ],
"name" : "pipeline-123123",
"description" : "",
"project_id" : "bc97c4d99c7d4f98bb6cd104a77fddd6",
"project_name" : "CloudPipelineTest-Copy"
},
"changeInfo" : null
} Example Responses
Status code: 200
OK
{
"task_id" : "eafaff0bf9094d3d8456d13dddf67b40"
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot