
# 查询流水线的旧版运行记录 - ListPipelineLegacyRuns
#### 功能介绍
查询流水线的旧版运行记录
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-pipeline/pipeline_03_0006.html)。
#### URI
POST /v5/{project_id}/api/pipelines/{pipeline_id}/pipeline-runs/list-legacy
表1路径参数 
| 参数          | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|:---|
| project_id  | 是    | String | **参数解释**： 项目ID，获取方式请参见[获取项目ID](https://support.huaweicloud.com/api-pipeline/pipeline_03_0036.html)。 **约束限制**： 不涉及。 **取值范围**： 32位字符，由数字和字母组成。 **默认取值**： 不涉及。                               |
| pipeline_id | 是    | String | **参数解释**： 流水线ID，可以通过[查询流水线列表](https://support.huaweicloud.com/api-pipeline/ListPipelines.html)接口获取，其中pipelines.pipelineId即为流水线ID。 **约束限制**： 不涉及。 **取值范围**： 32位字符，由数字和字母组成。 **默认取值**： 不涉及。 |
   
#### 请求参数
表2请求Body参数 
| 参数         | 是否必选 | 参数类型   | 描述                              |
|:---|:---|:---|:---|
| offset     | 是    | Long   | 偏移量                             |
| limit      | 是    | Long   | 单页条数                            |
| status     | 否    | String | 状态                              |
| sort_key   | 否    | String | 排序的KEY                          |
| sort_dir   | 否    | String | 排序类型，非必选。asc按排序字段升序，desc按排序字段降序 |
| start_time | 是    | String | 起始时间                            |
| end_time   | 是    | String | 结束时间                            |
   
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数            | 参数类型                                                                              | 描述                                                                                                                                                              |
|:---|:---|:---|
| offset        | Integer                                                                           | 偏移量                                                                                                                                                             |
| limit         | Integer                                                                           | 单页条数                                                                                                                                                            |
| total         | Integer                                                                           | **参数解释**： 总条目数量。 **取值范围**： 大于等于0。 |
| pipeline_runs | Array of [pipeline_runs] objects | 详情列表                                                                                                                                                            |
   
 表4pipeline_runs 
| 参数                 | 参数类型                                                                                      | 描述                                                                                                 |
|:---|:---|:---|
| pipeline_id        | String                                                                                    | 流水线ID                                                                                              |
| pipeline_run_id    | String                                                                                    | 流水线运行实例ID，[启动流水线](https://support.huaweicloud.com/api-pipeline/RunPipeline.html)接口的返回值即为流水线运行实例ID。 |
| executor_id        | String                                                                                    | 执行人ID                                                                                              |
| executor_name      | String                                                                                    | 执行人名称                                                                                              |
| executor_user_name | String                                                                                    | 执行人用户名                                                                                             |
| stage_status_list  | Array of [stage_status_list] objects | 阶段状态                                                                                               |
| status             | String                                                                                    | 运行状态                                                                                               |
| run_number         | Integer                                                                                   | 运行序号                                                                                               |
| trigger_type       | String                                                                                    | 触发类型                                                                                               |
| build_params       | String                                                                                    | 构建参数                                                                                               |
| artifact_params    | String                                                                                    | 构建产物参数                                                                                             |
| start_time         | Integer                                                                                   | 开始时间                                                                                               |
| end_time           | Integer                                                                                   | 结束时间                                                                                               |
| modify_url         | String                                                                                    | 修改URL                                                                                              |
| detail_url         | String                                                                                    | 详情URL                                                                                              |
   
 表5stage_status_list 
| 参数         | 参数类型    | 描述   |
|:---|:---|:---|
| id         | String  | 阶段ID |
| name       | String  | 阶段名称 |
| sequence   | Integer | 阶段序号 |
| status     | String  | 阶段状态 |
| start_time | String  | 开始时间 |
| end_time   | String  | 结束时间 |
   
#### 请求示例
```
POST https://(endpoint)/v5/db8d07265e24426598b3eb03a7818972/api/pipelines/e69862ac24f843fcb4ce4d5fe88ebcb7/pipeline-runs/list-legacy
{
  "offset" : 0,
  "limit" : 10,
  "status" : null,
  "sort_key" : "start_time",
  "sort_dir" : "",
  "start_time" : "2024-05-22 00:00:00",
  "end_time" : "2024-06-21 14:35:40"
}
```
#### 响应示例
**状态码：200**
响应体
```
{
  "offset" : 0,
  "limit" : 10,
  "total" : 1,
  "pipeline_runs" : [ {
    "pipeline_id" : "e69862ac24f843fcb4ce4d5fe88ebcb7",
    "pipeline_run_id" : "703177350",
    "executor_id" : "847a5317086c41798469d0868535943a",
    "executor_name" : "be123",
    "executor_user_name" : "test",
    "stage_status_list" : [ {
      "id" : "",
      "name" : "流水线源",
      "sequence" : 0,
      "status" : "COMPLETED",
      "start_time" : "2024-06-21 14:38:07",
      "end_time" : "2024-06-21 14:38:07"
    }, {
      "id" : "",
      "name" : "构建和检查",
      "sequence" : 1,
      "status" : "COMPLETED",
      "start_time" : "2024-06-21 14:38:07",
      "end_time" : "2024-06-21 14:38:07"
    } ],
    "status" : "COMPLETED",
    "run_number" : 1,
    "trigger_type" : "Manual",
    "build_params" : null,
    "artifact_params" : null,
    "start_time" : 1718951888000,
    "end_time" : 1718951888000,
    "modify_url" : null,
    "detail_url" : null
  } ]
}
```
#### 状态码
| 状态码 | 描述  |
|:---|:---|
| 200 | 响应体 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-pipeline/ErrorCode.html)。
