文档首页/ 流水线 CodeArts Pipeline/ API参考/ API/ 流水线管理/ 获取流水线状态/获取流水线执行详情
更新时间:2024-06-14 GMT+08:00

获取流水线状态/获取流水线执行详情

功能介绍

获取流水线状态/获取流水线执行详情,仅返回有执行记录的流水线数据

调用方法

请参见如何调用API

URI

GET /v5/{project_id}/api/pipelines/{pipeline_id}/pipeline-runs/detail

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID

pipeline_id

String

流水线ID

表2 Query参数

参数

是否必选

参数类型

描述

pipeline_run_id

String

流水线运行实例ID

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

id

String

流水线运行实例ID

pipeline_id

String

流水线ID

manifest_version

String

流水线版本

name

String

流水线名称

description

String

运行描述

is_publish

Boolean

是否为变更流水线

executor_id

String

运行人ID

executor_name

String

运行人名称

status

String

状态

trigger_type

String

触发类型

run_number

Integer

运行序号

start_time

Long

开始时间

end_time

Long

结束时间

stages

Array of StageRun objects

阶段信息

domain_id

String

租户ID

project_id

String

项目ID

region

String

局点

component_id

String

组件ID

language

String

语言

sources

Array of RunPipelineSource objects

运行源信息

artifacts

Array of PackageInfo objects

流水线运行产物

subject_id

String

流水线运行实例ID

group_id

String

分组ID

group_name

String

分组名称

detail_url

String

详情页地址

current_system_time

Long

当前系统时间

表5 StageRun

参数

参数类型

描述

id

String

阶段ID

category

String

阶段类型

name

String

阶段名称

identifier

String

唯一标识

run_always

Boolean

是否总是运行

parallel

String

是否并行

is_select

Boolean

是否选中

sequence

Integer

序列号

depends_on

Array of strings

依赖

condition

String

运行条件

status

String

状态

start_time

Long

开始时间

end_time

Long

结束时间

pre

Array of StepRun objects

阶段准入

post

Array of StepRun objects

阶段准出

jobs

Array of JobRun objects

任务

表6 JobRun

参数

参数类型

描述

id

String

任务ID

category

String

任务类型

sequence

Integer

序列号

async

String

是否异步

name

String

任务名称

identifier

String

任务唯一标识

depends_on

Array of strings

依赖

condition

String

运行条件

resource

String

执行资源

is_select

Boolean

是否选中

timeout

String

任务超时设置

last_dispatch_id

String

任务上次下发ID

status

String

状态

message

String

错误信息

start_time

Long

开始时间

end_time

Long

结束时间

steps

Array of StepRun objects

步骤

exec_id

String

任务执行ID

表7 StepRun

参数

参数类型

描述

name

String

步骤名称

task

String

步骤插件

business_type

String

插件业务类型

inputs

Array of inputs objects

输入参数

sequence

Integer

序列号

official_task_version

String

官方插件版本号

identifier

String

唯一标识符

multi_step_editable

Integer

是否可编辑

id

String

步骤ID

endpoint_ids

Array of strings

扩展点

last_dispatch_id

String

上次下发任务ID

status

String

状态

message

String

错误消息

start_time

Long

开始时间

end_time

Long

结束时间

表8 inputs

参数

参数类型

描述

key

String

输入参数名

value

Object

输入参数值

表9 RunPipelineSource

参数

参数类型

描述

type

String

源类型

params

params object

源参数

表10 params

参数

参数类型

描述

git_type

String

代码仓类型

git_url

String

代码仓https地址

ssh_git_url

String

代码仓ssh地址

web_url

String

代码仓页面地址

repo_name

String

代码仓名

default_branch

String

默认分支

endpoint_id

String

扩展点ID

codehub_id

String

Repo代码仓ID

alias

String

代码仓别名

build_params

build_params object

构建参数

表11 build_params

参数

参数类型

描述

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

source_codehub_id

String

源Repo代码仓ID

source_codehub_url

String

源Repo代码仓地址

source_codehub_http_url

String

源Repo代码仓http地址

表12 PackageInfo

参数

参数类型

描述

name

String

产物名

packageType

String

产物类型

version

String

产物版本号

downloadUrl

String

产物下载地址

请求示例

GET https://{endpoint}/v5/54f90b75fc1447b1b65e8d3a9f77923d/api/pipelines/e5460d1d403146a1935c2d4b68ef506c/pipeline-runs/detail

响应示例

状态码: 200

OK

{
  "id" : "25adfa6784124cfc9b9274ceaecf9957",
  "pipeline_id" : "98b6ea1536374df883bcc3b129bca4e9",
  "manifest_version" : "3.0",
  "name" : "子流水线qqq",
  "description" : null,
  "is_publish" : false,
  "executor_id" : "847a5317086c41798469d0868535943a",
  "executor_name" : "beta环境账号",
  "status" : "COMPLETED",
  "trigger_type" : "Manual",
  "run_number" : 1,
  "start_time" : 1674207197000,
  "end_time" : 1674207197000,
  "stages" : [ {
    "id" : "aac8063fbf084eec9722c77ece6dd283",
    "category" : null,
    "name" : "阶段_1",
    "identifier" : "0",
    "run_always" : false,
    "parallel" : null,
    "is_select" : true,
    "sequence" : 0,
    "depends_on" : [ ],
    "condition" : null,
    "status" : "COMPLETED",
    "start_time" : 1674207197000,
    "end_time" : 1674207197000,
    "pre" : [ {
      "name" : null,
      "task" : "official_devcloud_autoTrigger",
      "business_type" : null,
      "inputs" : null,
      "sequence" : 0,
      "official_task_version" : null,
      "identifier" : null,
      "multi_step_editable" : 0,
      "id" : "5a03bdb6ad2848ac972ba21744627a8c",
      "endpoint_ids" : null,
      "last_dispatch_id" : "6b3fa4c664844f33abc02053ddd76f62",
      "status" : "COMPLETED",
      "message" : null,
      "start_time" : 1674207197000,
      "end_time" : 1674207197000
    } ],
    "post" : [ ],
    "jobs" : [ {
      "id" : "1cde6a3815164cd18d0fa4038f876e46",
      "category" : null,
      "sequence" : 0,
      "async" : null,
      "name" : "新建任务",
      "identifier" : "1674207161661b4a41d77-a478-4538-870b-ffb589c1af06",
      "depends_on" : [ ],
      "condition" : null,
      "resource" : null,
      "is_select" : true,
      "timeout" : "",
      "last_dispatch_id" : null,
      "status" : "COMPLETED",
      "message" : "not found steps",
      "start_time" : 1674207197000,
      "end_time" : 1674207197000,
      "steps" : [ ]
    } ]
  } ],
  "domain_id" : "ce8df55870164338a72d7e828a966a2a",
  "project_id" : "6428c2e2b4b64affa14ec80896695c49",
  "region" : "region01",
  "component_id" : "",
  "language" : "zh-cn",
  "sources" : [ {
    "type" : "code",
    "params" : {
      "git_type" : "codehub",
      "git_url" : "https://example.com/clsyz00001/aaaaa.git",
      "ssh_git_url" : "git@example.com:clsyz00001/aaaaa.git",
      "web_url" : "",
      "repo_name" : "aaaaa",
      "default_branch" : "master",
      "endpoint_id" : "",
      "codehub_id" : "2111677704",
      "alias" : "",
      "build_params" : {
        "action" : null,
        "build_type" : "branch",
        "commit_id" : "990ea057751d299f5575aac25bf97e88a60b461e",
        "event_type" : "Manual",
        "merge_id" : null,
        "message" : "新建文件 Dockerfile",
        "source_branch" : null,
        "tag" : null,
        "target_branch" : "master",
        "codehub_id" : "2111677704"
      }
    }
  } ],
  "artifacts" : null,
  "subject_id" : "25adfa6784124cfc9b9274ceaecf9957"
}

SDK代码示例

SDK代码示例如下。

 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
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 ShowPipelineRunDetailSolution {

    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();
        ShowPipelineRunDetailRequest request = new ShowPipelineRunDetailRequest();
        request.withPipelineRunId("<pipeline_run_id>");
        try {
            ShowPipelineRunDetailResponse response = client.showPipelineRunDetail(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());
        }
    }
}
 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
# 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 = ShowPipelineRunDetailRequest()
        request.pipeline_run_id = "<pipeline_run_id>"
        response = client.show_pipeline_run_detail(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
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.ShowPipelineRunDetailRequest{}
	pipelineRunIdRequest:= "<pipeline_run_id>"
	request.PipelineRunId = &pipelineRunIdRequest
	response, err := client.ShowPipelineRunDetail(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

错误码

请参见错误码