Help Center/ CodeArts Pipeline/ API Reference/ API/ Pipeline Management/ Obtaining Pipeline Execution Records
Updated on 2024-06-14 GMT+08:00

Obtaining Pipeline Execution Records

Function

This API is used to obtain pipeline execution records.

Calling Method

For details, see Calling APIs.

URI

POST /v5/{project_id}/api/pipelines/{pipeline_id}/pipeline-runs/list

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

pipeline_id

Yes

String

Pipeline ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

status

No

Array of strings

Status.

start_time

No

String

Start time.

end_time

No

String

End time.

offset

No

Long

Initial offset.

limit

No

Long

Query size.

sort_key

No

String

Sorting field name.

sort_dir

No

String

Sorting rule.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

offset

Integer

Initial offset.

limit

Integer

Query size.

total

Integer

Total number.

pipeline_runs

Array of pipeline_runs objects

Pipeline running information.

Table 5 pipeline_runs

Parameter

Type

Description

pipeline_id

String

Pipeline ID.

pipeline_run_id

String

Pipeline run ID.

executor_id

String

Executor ID.

executor_name

String

Executor name.

stage_status_list

Array of stage_status_list objects

Stage information.

status

String

Status.

run_number

Integer

Running number.

trigger_type

String

Trigger type.

build_params

build_params object

Build parameters.

artifact_params

artifact_params object

Artifact source parameters.

start_time

Long

Start time.

end_time

Long

End time.

detail_url

String

Address of the details page.

modify_url

String

Address of the change page.

Table 6 stage_status_list

Parameter

Type

Description

name

String

Stage name.

sequence

Integer

Serial number.

status

String

Status.

start_time

String

Start time.

end_time

String

End time.

id

String

Stage ID.

Table 7 build_params

Parameter

Type

Description

action

String

Event type of merge requests.

build_type

String

Triggered by branch or by tag.

commit_id

String

Code repository commit ID.

event_type

String

Event type for running.

merge_id

String

Merge request ID.

message

String

Code commit message.

source_branch

String

Source branch.

tag

String

Tag.

target_branch

String

Target branch.

codehub_id

String

Repo repository ID.

git_url

String

HTTPS address of the code repository.

source_codehub_id

String

Source Repo repository ID.

source_codehub_url

String

Source Repo repository address.

source_codehub_http_url

String

HTTP address of the source Repo repository.

Table 8 artifact_params

Parameter

Type

Description

version

String

Package version.

branch_filter

String

Branch filter.

package_name

String

Package name.

organization

String

Docker organization.

Example Requests

This API is used to obtain pipeline execution records. Set the start offset to 0, quantity to 10, start timestamp to 1677513600000, and end timestamp to 1678118399000, and sort the query results in descending order of the start time.

POST https://{endpoint}/v5/54f90b75fc1447b1b65e8d3a9f77923d/api/pipelines/e5460d1d403146a1935c2d4b68ef506c/pipeline-runs/list

{
  "offset" : 0,
  "limit" : 10,
  "status" : [ "COMPLETED", "RUNNING", "FAILED", "CANCELED", "PAUSED", "SUSPEND", "QUEUED" ],
  "sort_key" : "start_time",
  "sort_dir" : "DESC",
  "start_time" : 1677513600000,
  "end_time" : 1678118399000
}

Example Responses

Status code: 200

OK

{
  "offset" : 0,
  "limit" : 10,
  "total" : 1,
  "pipeline_runs" : [ {
    "pipeline_id" : "24949d4f4453495f8e5a76f993af7f43",
    "pipeline_run_id" : "ddb7532cb0e948f2af7bb4397fc19864",
    "executor_id" : "847a5317086c41798469d0868535943a",
    "executor_name" : "Beta environment account",
    "stage_status_list" : [ {
      "name" : "Phase_1",
      "sequence" : 0,
      "status" : "COMPLETED",
      "start_time" : "2023-03-06 10:04:46",
      "end_time" : "2023-03-06 10:04:46"
    } ],
    "status" : "COMPLETED",
    "run_number" : 11,
    "trigger_type" : "Manual",
    "build_params" : {
      "action" : null,
      "build_type" : "branch",
      "commit_id" : "990ea057751d299f5575aac25bf97e88a60b461e",
      "event_type" : "Manual",
      "merge_id" : null,
      "message" : "Creating a Dockerfile",
      "source_branch" : null,
      "tag" : null,
      "target_branch" : "cloud_pipeline_release_1674026917209",
      "codehub_id" : "2111677704",
      "git_url" : "https://example.com/clsyz00001/aaaaa.git"
    },
    "artifact_params" : null,
    "start_time" : 1678066487000,
    "end_time" : 1678066488000
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

This API is used to obtain pipeline execution records. Set the start offset to 0, quantity to 10, start timestamp to 1677513600000, and end timestamp to 1678118399000, and sort the query results in descending order of the start time.

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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.*;

import java.util.List;
import java.util.ArrayList;

public class ListPipelineRunsSolution {

    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();
        ListPipelineRunsRequest request = new ListPipelineRunsRequest();
        ListPipelineRunsQuery body = new ListPipelineRunsQuery();
        List<String> listbodyStatus = new ArrayList<>();
        listbodyStatus.add("COMPLETED");
        listbodyStatus.add("RUNNING");
        listbodyStatus.add("FAILED");
        listbodyStatus.add("CANCELED");
        listbodyStatus.add("PAUSED");
        listbodyStatus.add("SUSPEND");
        listbodyStatus.add("QUEUED");
        body.withSortDir("DESC");
        body.withSortKey("start_time");
        body.withLimit(10L);
        body.withOffset(0L);
        body.withEndTime("1678118399000");
        body.withStartTime("1677513600000");
        body.withStatus(listbodyStatus);
        request.withBody(body);
        try {
            ListPipelineRunsResponse response = client.listPipelineRuns(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());
        }
    }
}

This API is used to obtain pipeline execution records. Set the start offset to 0, quantity to 10, start timestamp to 1677513600000, and end timestamp to 1678118399000, and sort the query results in descending order of the start time.

 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
# 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 = ListPipelineRunsRequest()
        listStatusbody = [
            "COMPLETED",
            "RUNNING",
            "FAILED",
            "CANCELED",
            "PAUSED",
            "SUSPEND",
            "QUEUED"
        ]
        request.body = ListPipelineRunsQuery(
            sort_dir="DESC",
            sort_key="start_time",
            limit=10,
            offset=0,
            end_time="1678118399000",
            start_time="1677513600000",
            status=listStatusbody
        )
        response = client.list_pipeline_runs(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

This API is used to obtain pipeline execution records. Set the start offset to 0, quantity to 10, start timestamp to 1677513600000, and end timestamp to 1678118399000, and sort the query results in descending order of the start time.

 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
51
52
53
54
55
56
57
58
59
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.ListPipelineRunsRequest{}
	var listStatusbody = []string{
        "COMPLETED",
	    "RUNNING",
	    "FAILED",
	    "CANCELED",
	    "PAUSED",
	    "SUSPEND",
	    "QUEUED",
    }
	sortDirListPipelineRunsQuery:= "DESC"
	sortKeyListPipelineRunsQuery:= "start_time"
	limitListPipelineRunsQuery:= int64(10)
	offsetListPipelineRunsQuery:= int64(0)
	endTimeListPipelineRunsQuery:= "1678118399000"
	startTimeListPipelineRunsQuery:= "1677513600000"
	request.Body = &model.ListPipelineRunsQuery{
		SortDir: &sortDirListPipelineRunsQuery,
		SortKey: &sortKeyListPipelineRunsQuery,
		Limit: &limitListPipelineRunsQuery,
		Offset: &offsetListPipelineRunsQuery,
		EndTime: &endTimeListPipelineRunsQuery,
		StartTime: &startTimeListPipelineRunsQuery,
		Status: &listStatusbody,
	}
	response, err := client.ListPipelineRuns(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

OK

401

Unauthorized

403

Forbidden

404

Not Found

Error Codes

See Error Codes.