文档首页/ 流水线 CodeArts Pipeline/ API参考/ 应用示例/ 示例3:获取流水线状态
更新时间:2024-01-16 GMT+08:00

示例3:获取流水线状态

场景描述

本章将指导您通过API获取流水线状态。

API的调用方法请参见3-如何调用API

约束限制

流水线任务已经在流水线服务中创建。

涉及接口

通过用户token、流水线id等请求参数获取流水线状态

操作步骤

  1. 查询流水线任务执行状态。

    • 接口信息

      URI:POST v3/pipelines/{pipeline_id}/status

      API文档详情请参见:获取流水线状态

    • 请求示例
      GET  https://cloudpipeline-ext.ap-southeast-3.myhuaweicloud.com/v3/pipelines/{pipeline_id}/status
    • 响应示例
      {
          "executor": "xxx",
          "status": "completed",
          "outcome": "success",
          "parameters": [
              {
                  "name": "serviceName",
                  "value": "test测试"
              },
              {
                  "name": "codeBranch",
                  "value": "master"
              },
              {
                  "name": "releaseVersion",
                  "value": "1.0.0"
              }
          ],
          "states": [
              {
                  "id": "state_3",
                  "name": "源代码",
                  "type": "stage",
                  "status": "completed",
                  "outcome": "success",
                  "children": [],
                  "start_time": "2020-09-01 17:13:18",
                  "end_time": "2020-09-01 17:13:18",
                  "elapsed_time": "0"
              },
              {
                  "id": "state_4",
                  "name": "构建",
                  "type": "stage",
                  "status": "completed",
                  "outcome": "success",
                  "children": [
                      {
                          "id": "Task_1",
                          "name": "默认任务",
                          "type": "task",
                          "status": "completed",
                          "outcome": "success",
                          "start_time": "2020-09-01 17:13:18",
                          "end_time": "2020-09-01 17:16:22",
                          "elapsed_time": "183",
                          "error_code": null,
                          "error_msg": null,
                          "detail_url": null
                      }
                  ],
                  "start_time": "2020-09-01 17:13:18",
                  "end_time": "2020-09-01 17:16:22",
                  "elapsed_time": "183"
              },
              {
                  "id": "state_5",
                  "name": "发布仓库",
                  "type": "stage",
                  "status": "completed",
                  "outcome": "success",
                  "children": [],
                  "start_time": "2020-09-01 17:16:22",
                  "end_time": "2020-09-01 17:16:22",
                  "elapsed_time": "0"
              }
          ],
          "pipeline_id": "824e784b3f43492e99152a4....",
          "pipeline_name": "pipeline_测试",
          "build_id": "xxxx",
          "start_time": "2020-09-01 17:13:18",
          "end_time": "2020-09-01 17:16:22",
          "elapsed_time": "184",
          "detail_url": "https://xxxxxx/pipeline/detail/824e784b3f43492e99152a....."
      }