Help Center> CodeArts Pipeline> API Reference> API> Pipeline Management> Creating a Pipeline Using a Template
Updated on 2023-12-08 GMT+08:00

Creating a Pipeline Using a Template

Function

Creating a Pipeline Using a Template

URI

POST /v5/{project_id}/api/pipeline-templates/{template_id}/create-pipeline

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

template_id

Yes

String

The template ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

component_id

No

String

Microservice ID

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. Can be obtained by calling the IAM API for obtaining the user token (the value of X-Subject-Token in the response header).

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Pipeline name

description

No

String

Description

is_publish

Yes

Boolean

Indicates whether the pipeline is a change pipeline.

sources

Yes

Array of CodeSource objects

Pipeline Source

variables

No

Array of variables objects

Pipeline Parameters

Table 5 CodeSource

Parameter

Mandatory

Type

Description

type

No

String

Pipeline Source Type

params

No

params object

Pipeline Source Parameters

Table 6 params

Parameter

Mandatory

Type

Description

git_type

No

String

Git Type

codehub_id

No

String

Repo code repository ID

endpoint_id

No

String

Extension point ID.

default_branch

No

String

Default Branch

git_url

No

String

git link

ssh_git_url

No

String

ssh_git link

web_url

No

String

Web page URL.

repo_name

No

String

Pipeline Source Name

alias

No

String

Alias of the code repository. The alias can contain a maximum of 128 characters, including uppercase letters, lowercase letters, digits, and underscores (_).

Table 7 variables

Parameter

Mandatory

Type

Description

name

No

String

Parameter

sequence

No

Integer

Parameter No.

type

No

String

Type

value

No

String

Parameter

is_secret

No

Boolean

Indicates whether the parameter is private.

description

No

String

Description

is_runtime

No

Boolean

Indicates whether to set during running.

is_reset

No

Boolean

Reset or Not

latest_value

No

String

Last Parameter Value

limits

No

Array of strings

Enumerated Value

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

pipeline_id

String

Pipeline ID

Example Requests

Create a pipeline based on a template. Set the pipeline name to New pipeline-2023041516464511, code repository to test001.git, and default branch to master.

POST https://{endpoint}/v5/54f90b75fc1447b1b65e8d3a9f77923d/api/pipeline-templates/434d660a96de423a935a0571c2223bca/create-pipeline

{
  "name" : "New Pipeline - 2023041516464511",
  "description" : "",
  "is_publish" : false,
  "sources" : [ {
    "type" : "code",
    "params" : {
      "git_type" : "codehub",
      "codehub_id" : "2111717853",
      "endpoint_id" : "",
      "default_branch" : "master",
      "git_url" : "https://example.com/cjrTest00002/test001.git",
      "ssh_git_url" : "git@example.com:cjrTest00002/test001.git",
      "web_url" : "",
      "repo_name" : "test001",
      "alias" : ""
    }
  } ]
}

Example Responses

Status code: 200

OK

{
  "pipeline_id" : "ad6b7f66283a45be9c1f82b06c831e59"
}

Status Codes

Status Code

Description

200

OK

401

Unauthorized

403

Forbidden

404

Not Found

Error Codes

See Error Codes.