获取流水线列表/获取项目下流水线执行状况
功能介绍
获取流水线列表/获取项目下流水线执行状况
调用方法
请参见如何调用API。
URI
POST /v5/{project_id}/api/pipelines/list
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_ids |
否 |
Array of strings |
项目ID列表 |
component_id |
否 |
String |
组件ID |
name |
否 |
String |
流水线名称,支持模糊查询 |
status |
否 |
Array of strings |
状态 |
is_publish |
否 |
Boolean |
是否为变更流水线 |
creator_ids |
否 |
Array of strings |
创建人ID列表 |
executor_ids |
否 |
Array of strings |
执行人ID列表 |
start_time |
否 |
String |
开始时间 |
end_time |
否 |
String |
结束时间 |
offset |
否 |
Long |
起始偏移 |
limit |
否 |
Long |
查询数量 |
sort_key |
否 |
String |
排序字段名称 |
sort_dir |
否 |
String |
排序规则 |
group_path_id |
否 |
String |
流水线分组ID |
by_group |
否 |
Boolean |
是否分组查询 |
query_new |
否 |
Boolean |
是否只查询新版流水线 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
offset |
Integer |
起始偏移 |
limit |
Integer |
查询大小 |
total |
Integer |
总数 |
pipelines |
Array of pipelines objects |
流水线 |
参数 |
参数类型 |
描述 |
---|---|---|
pipeline_id |
String |
流水线ID |
name |
String |
流水线名称 |
project_id |
String |
项目ID |
project_name |
String |
项目名称 |
component_id |
String |
组件ID |
is_publish |
Boolean |
是否为变更流水线 |
is_collect |
Boolean |
是否收藏此流水线 |
manifest_version |
String |
流水线版本 |
create_time |
Long |
创建时间 |
latest_run |
latest_run object |
最近一次运行信息 |
convert_sign |
Integer |
旧版转新版标识 |
参数 |
参数类型 |
描述 |
---|---|---|
pipeline_id |
String |
流水线ID |
pipeline_run_id |
String |
流水线运行实例ID |
executor_id |
String |
执行人ID |
executor_name |
String |
执行人名称 |
stage_status_list |
Array of stage_status_list objects |
阶段信息列表 |
status |
String |
状态 |
run_number |
Integer |
运行序号 |
trigger_type |
String |
触发类型 |
build_params |
build_params object |
构建参数 |
artifact_params |
artifact_params object |
制品源参数 |
start_time |
Long |
开始时间 |
end_time |
Long |
结束时间 |
modify_url |
String |
修改页地址 |
detail_url |
String |
详情页地址 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
阶段名 |
sequence |
Integer |
序列号 |
status |
String |
状态 |
start_time |
String |
开始时间 |
end_time |
String |
结束时间 |
id |
String |
阶段ID |
参数 |
参数类型 |
描述 |
---|---|---|
action |
String |
合并请求事件类型 |
build_type |
String |
基于分支还是tag运行 |
commit_id |
String |
代码仓提交ID |
event_type |
String |
运行事件类型 |
merge_id |
String |
合并请求ID |
message |
String |
代码仓提交信息 |
source_branch |
String |
源分支 |
tag |
String |
标签 |
target_branch |
String |
目标分支 |
codehub_id |
String |
Repo代码仓ID |
git_url |
String |
代码仓https地址 |
source_codehub_id |
String |
源Repo代码仓ID |
source_codehub_url |
String |
源Repo代码仓地址 |
source_codehub_http_url |
String |
源Repo代码仓http地址 |
请求示例
获取流水线列表。 指定查询的起始偏移量为0,数量为10。
POST https://{endpoint}/v5/54f90b75fc1447b1b65e8d3a9f77923d/api/pipelines/list { "offset" : 0, "limit" : 10, "name" : "" }
响应示例
状态码: 200
OK
{ "offset" : 0, "limit" : 10, "total" : 1, "pipelines" : [ { "pipeline_id" : "cd65d6f2dc17493e97eb5175f872761a", "name" : "新建流水线-20230222181032", "project_id" : "6428c2e2b4b64affa14ec80896695c49", "component_id" : "7bb171e9e9fc415dbd1666ceb68668da", "is_publish" : true, "is_collect" : false, "manifest_version" : "3.0", "create_time" : 1677060662000, "latest_run" : { "pipeline_id" : "cd65d6f2dc17493e97eb5175f872761a", "pipeline_run_id" : "88a195482b8a48a1808e87ec21565c2f", "executor_id" : "847a5317086c41798469d0868535943a", "executor_name" : "beta环境账号", "stage_status_list" : [ { "name" : "合并集成分支", "sequence" : 0, "status" : "FAILED", "start_time" : "2023-02-22 18:12:25", "end_time" : "2023-02-22 18:12:32" }, { "name" : "阶段_1", "sequence" : 1, "status" : "INIT", "start_time" : null, "end_time" : null }, { "name" : "合并主干", "sequence" : 1, "status" : "INIT", "start_time" : null, "end_time" : null } ], "status" : "FAILED", "run_number" : 1, "trigger_type" : "Manual", "build_params" : null, "artifact_params" : null, "start_time" : 1677060745000, "end_time" : 1677060752000 } } ] }
SDK代码示例
SDK代码示例如下。
获取流水线列表。 指定查询的起始偏移量为0,数量为10。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.codeartspipeline.v2.region.CodeArtsPipelineRegion; import com.huaweicloud.sdk.codeartspipeline.v2.*; import com.huaweicloud.sdk.codeartspipeline.v2.model.*; public class ListPipelinesSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CodeArtsPipelineClient client = CodeArtsPipelineClient.newBuilder() .withCredential(auth) .withRegion(CodeArtsPipelineRegion.valueOf("<YOUR REGION>")) .build(); ListPipelinesRequest request = new ListPipelinesRequest(); ListPipelineQuery body = new ListPipelineQuery(); body.withLimit(10L); body.withOffset(0L); body.withName(""); request.withBody(body); try { ListPipelinesResponse response = client.listPipelines(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
获取流水线列表。 指定查询的起始偏移量为0,数量为10。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcodeartspipeline.v2.region.codeartspipeline_region import CodeArtsPipelineRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcodeartspipeline.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = CodeArtsPipelineClient.new_builder() \ .with_credentials(credentials) \ .with_region(CodeArtsPipelineRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListPipelinesRequest() request.body = ListPipelineQuery( limit=10, offset=0, name="" ) response = client.list_pipelines(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
获取流水线列表。 指定查询的起始偏移量为0,数量为10。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" codeartspipeline "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := codeartspipeline.NewCodeArtsPipelineClient( codeartspipeline.CodeArtsPipelineClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListPipelinesRequest{} limitListPipelineQuery:= int64(10) offsetListPipelineQuery:= int64(0) nameListPipelineQuery:= "" request.Body = &model.ListPipelineQuery{ Limit: &limitListPipelineQuery, Offset: &offsetListPipelineQuery, Name: &nameListPipelineQuery, } response, err := client.ListPipelines(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
错误码
请参见错误码。