파이프라인 API
Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
이 API를 사용하여 CI/CD 파이프라인과 상호 작용합니다. 기본적으로 하위 파이프라인은 결과에 포함되지 않습니다. 결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요. scope가 branches 또는 tags로 설정되면 API는 각 브랜치 또는 태그 ref의 최신 파이프라인만 반환합니다.
이 API를 사용하여 CI/CD 파이프라인과 상호 작용합니다.
프로젝트 파이프라인 목록 조회#
히스토리
- 응답의
name도입 GitLab 15.11에서pipeline_name_in_api라는 플래그와 함께. 기본적으로 비활성화됨. - 요청의
name도입 15.11에서pipeline_name_search라는 플래그와 함께. 기본적으로 비활성화됨. - 응답의
name일반 공개 GitLab 16.3에서. 기능 플래그pipeline_name_in_api제거됨. - 요청의
name일반 공개 GitLab 16.9에서. 기능 플래그pipeline_name_search제거됨. source가parent_pipeline으로 설정된 하위 파이프라인 반환 지원 도입 GitLab 17.0에서.
프로젝트의 파이프라인을 나열합니다.
기본적으로 하위 파이프라인은 결과에 포함되지 않습니다. 하위 파이프라인을 반환하려면 source를 parent_pipeline으로 설정하세요.
GET /projects/:id/pipelines
결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트의 ID 또는 URL 인코딩된 경로. |
name |
string | No | 지정된 이름의 파이프라인을 반환합니다. |
order_by |
string | No | 파이프라인 정렬 기준 필드: id, status, ref, updated_at 또는 user_id (기본값: id). |
ref |
string | No | 지정된 브랜치 또는 태그의 파이프라인을 반환합니다. |
scope |
string | No | 지정된 범위의 파이프라인을 반환합니다: running, pending, finished, branches 또는 tags. |
sha |
string | No | 지정된 커밋 SHA의 파이프라인을 반환합니다. |
sort |
string | No | 정렬 순서: asc 또는 desc (기본값: desc). |
source |
string | No | 지정된 소스의 파이프라인을 반환합니다. |
status |
string | No | 지정된 상태의 파이프라인을 반환합니다: created, waiting_for_resource, preparing, pending, running, success, failed, canceled, skipped, manual 또는 scheduled. |
updated_after |
datetime | No | 지정된 날짜 이후에 업데이트된 파이프라인을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)으로 예상됩니다. |
updated_before |
datetime | No | 지정된 날짜 이전에 업데이트된 파이프라인을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)으로 예상됩니다. |
created_after |
datetime | No | 지정된 날짜 이후에 생성된 파이프라인을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)으로 예상됩니다. |
created_before |
datetime | No | 지정된 날짜 이전에 생성된 파이프라인을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)으로 예상됩니다. |
username |
string | No | 지정된 사용자 이름으로 트리거된 파이프라인을 반환합니다. |
yaml_errors |
boolean | No | 잘못된 구성의 파이프라인을 반환합니다. |
scope가 branches 또는 tags로 설정되면 API는 각 브랜치 또는 태그 ref의 최신 파이프라인만 반환합니다.
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines"
응답 예시
[
{
"id": 47,
"iid": 12,
"project_id": 1,
"status": "pending",
"source": "push",
"ref": "new-pipeline",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"name": "Build pipeline",
"web_url": "https://example.com/foo/bar/pipelines/47",
"created_at": "2016-08-11T11:28:34.085Z",
"updated_at": "2016-08-11T11:32:35.169Z"
},
{
"id": 48,
"iid": 13,
"project_id": 1,
"status": "pending",
"source": "web",
"ref": "new-pipeline",
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
"name": "Build pipeline",
"web_url": "https://example.com/foo/bar/pipelines/48",
"created_at": "2016-08-12T10:06:04.561Z",
"updated_at": "2016-08-12T10:09:56.223Z"
}
]
단일 파이프라인 조회#
히스토리
프로젝트에서 단일 파이프라인을 조회합니다.
단일 하위 파이프라인도 가져올 수 있습니다.
GET /projects/:id/pipelines/:pipeline_id
결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
응답 예시
{
"id": 287,
"iid": 144,
"project_id": 21,
"name": "Build pipeline",
"sha": "50f0acb76a40e34a4ff304f7347dcc6587da8a14",
"ref": "main",
"status": "success",
"source": "push",
"created_at": "2022-09-21T01:05:07.200Z",
"updated_at": "2022-09-21T01:05:50.185Z",
"web_url": "http://127.0.0.1:3000/test-group/test-project/-/pipelines/287",
"before_sha": "8a24fb3c5877a6d0b611ca41fc86edc174593e2b",
"tag": false,
"yaml_errors": null,
"user": {
"id": 1,
"username": "root",
"name": "Administrator",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://127.0.0.1:3000/root"
},
"started_at": "2022-09-21T01:05:14.197Z",
"finished_at": "2022-09-21T01:05:50.175Z",
"committed_at": null,
"duration": 34,
"queued_duration": 6,
"coverage": null,
"detailed_status": {
"icon": "status_success",
"text": "passed",
"label": "passed",
"group": "success",
"tooltip": "passed",
"has_details": false,
"details_path": "/test-group/test-project/-/pipelines/287",
"illustration": null,
"favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"
},
"archived": false
}
최신 파이프라인 조회#
히스토리
프로젝트의 특정 ref에서 가장 최근 커밋에 대한 최신 파이프라인을 조회합니다. 커밋에 대한 파이프라인이 없으면 403 상태 코드가 반환됩니다.
GET /projects/:id/pipelines/latest
결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
ref |
string | No | 최신 파이프라인을 확인할 브랜치 또는 태그입니다. 지정하지 않으면 기본 브랜치가 기본값입니다. |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/latest"
응답 예시
{
"id": 287,
"iid": 144,
"project_id": 21,
"name": "Build pipeline",
"sha": "50f0acb76a40e34a4ff304f7347dcc6587da8a14",
"ref": "main",
"status": "success",
"source": "push",
"created_at": "2022-09-21T01:05:07.200Z",
"updated_at": "2022-09-21T01:05:50.185Z",
"web_url": "http://127.0.0.1:3000/test-group/test-project/-/pipelines/287",
"before_sha": "8a24fb3c5877a6d0b611ca41fc86edc174593e2b",
"tag": false,
"yaml_errors": null,
"user": {
"id": 1,
"username": "root",
"name": "Administrator",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://127.0.0.1:3000/root"
},
"started_at": "2022-09-21T01:05:14.197Z",
"finished_at": "2022-09-21T01:05:50.175Z",
"committed_at": null,
"duration": 34,
"queued_duration": 6,
"coverage": null,
"detailed_status": {
"icon": "status_success",
"text": "passed",
"label": "passed",
"group": "success",
"tooltip": "passed",
"has_details": false,
"details_path": "/test-group/test-project/-/pipelines/287",
"illustration": null,
"favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"
},
"archived": false
}
파이프라인 변수 조회#
파이프라인의 파이프라인 변수를 조회합니다.
GET /projects/:id/pipelines/:pipeline_id/variables
결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46/variables"
응답 예시
[
{
"key": "RUN_NIGHTLY_BUILD",
"variable_type": "env_var",
"value": "true"
},
{
"key": "foo",
"value": "bar"
}
]
파이프라인의 테스트 보고서 조회#
이 API 라우트는 단위 테스트 보고서 기능의 일부입니다.
GET /projects/:id/pipelines/:pipeline_id/test_report
결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
요청 예시:
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46/test_report"
응답 예시:
{
"total_time": 5,
"total_count": 1,
"success_count": 1,
"failed_count": 0,
"skipped_count": 0,
"error_count": 0,
"test_suites": [
{
"name": "Secure",
"total_time": 5,
"total_count": 1,
"success_count": 1,
"failed_count": 0,
"skipped_count": 0,
"error_count": 0,
"test_cases": [
{
"status": "success",
"name": "Security Reports can create an auto-remediation MR",
"classname": "vulnerability_management_spec",
"execution_time": 5,
"system_output": null,
"stack_trace": null
}
]
}
]
}
파이프라인의 테스트 보고서 요약 조회#
이 API 라우트는 단위 테스트 보고서 기능의 일부입니다.
GET /projects/:id/pipelines/:pipeline_id/test_report_summary
결과의 페이지 매김을 제어하려면 page 및 per_page 페이지 매김 파라미터를 사용하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
요청 예시:
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46/test_report_summary"
응답 예시:
{
"total": {
"time": 1904,
"count": 3363,
"success": 3351,
"failed": 0,
"skipped": 12,
"error": 0,
"suite_error": null
},
"test_suites": [
{
"name": "test",
"total_time": 1904,
"total_count": 3363,
"success_count": 3351,
"failed_count": 0,
"skipped_count": 12,
"error_count": 0,
"build_ids": [
66004
],
"suite_error": null
}
]
}
새 파이프라인 생성#
히스토리
POST /projects/:id/pipeline
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
ref |
string | Yes | 파이프라인을 실행할 브랜치 또는 태그입니다. 머지 리퀘스트 파이프라인의 경우 머지 리퀘스트 엔드포인트를 사용하세요. |
variables |
array | No | 파이프라인에서 사용 가능한 변수를 포함하는 해시 배열로, [{ 'key': 'UPLOAD_TO_S3', 'variable_type': 'file', 'value': 'true' }, {'key': 'TEST', 'value': 'test variable'}] 구조와 일치합니다. variable_type을 제외하면 기본값은 env_var입니다. |
inputs |
hash | No | 파이프라인 생성 시 사용할 입력값을 키-값 쌍으로 포함하는 해시입니다. |
기본 예시:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipeline?ref=main"
입력값을 사용하는 요청 예시:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{"inputs": {"environment": "environment", "scan_security": false, "level": 3}}' \
--url "https://gitlab.example.com/api/v4/projects/1/pipeline?ref=main"
응답 예시
{
"id": 61,
"iid": 21,
"project_id": 1,
"sha": "384c444e840a515b23f21915ee5766b87068a70d",
"ref": "main",
"status": "pending",
"before_sha": "0000000000000000000000000000000000000000",
"tag": false,
"yaml_errors": null,
"user": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2016-11-04T09:36:13.747Z",
"updated_at": "2016-11-04T09:36:13.977Z",
"started_at": null,
"finished_at": null,
"committed_at": null,
"duration": null,
"queued_duration": 0.010,
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/61",
"archived": false
}
파이프라인의 작업 재시도#
히스토리
- 응답의
iid도입 GitLab 14.6에서.
파이프라인에서 실패하거나 취소된 작업을 재시도합니다. 파이프라인에 실패하거나 취소된 작업이 없으면 이 엔드포인트를 호출해도 효과가 없습니다.
POST /projects/:id/pipelines/:pipeline_id/retry
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry"
응답:
{
"id": 46,
"iid": 11,
"project_id": 1,
"status": "pending",
"ref": "main",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"tag": false,
"yaml_errors": null,
"user": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2016-08-11T11:28:34.085Z",
"updated_at": "2016-08-11T11:32:35.169Z",
"started_at": null,
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null,
"queued_duration": 0.010,
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46",
"archived": false
}
파이프라인의 모든 작업 취소#
POST /projects/:id/pipelines/:pipeline_id/cancel
이 엔드포인트는 파이프라인의 상태에 관계없이 성공 응답 200을 반환합니다.
자세한 내용은 이슈 414963을 참조하세요.
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel"
응답:
{
"id": 46,
"iid": 11,
"project_id": 1,
"status": "canceled",
"ref": "main",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"tag": false,
"yaml_errors": null,
"user": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2016-08-11T11:28:34.085Z",
"updated_at": "2016-08-11T11:32:35.169Z",
"started_at": null,
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null,
"queued_duration": 0.010,
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46",
"archived": false
}
파이프라인 삭제#
파이프라인을 삭제하면 모든 파이프라인 캐시가 만료되고 빌드, 로그, 아티팩트, 트리거와 같은 직접 관련된 모든 객체가 삭제됩니다. 이 작업은 취소할 수 없습니다.
파이프라인을 삭제해도 해당 하위 파이프라인은 자동으로 삭제되지 않습니다. 자세한 내용은 관련 이슈를 참조하세요.
DELETE /projects/:id/pipelines/:pipeline_id
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
pipeline_id |
integer | Yes | 파이프라인 ID |
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
파이프라인 메타데이터 업데이트#
파이프라인 메타데이터를 업데이트합니다. 메타데이터에는 파이프라인의 이름이 포함됩니다.
PUT /projects/:id/pipelines/:pipeline_id/metadata
| 속성 | 타입 | 필수 | 설명 |
|---|---|---|---|
id |
integer or string | Yes | 프로젝트 ID 또는 URL 인코딩된 프로젝트 경로 |
name |
string | Yes | 파이프라인의 새 이름 |
pipeline_id |
integer | Yes | 파이프라인 ID |
요청 예시:
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{"name": "Some new pipeline name"}' \
--url "https://gitlab.example.com/api/v4/projects/1/pipelines/46/metadata"
응답 예시:
{
"id": 46,
"iid": 11,
"project_id": 1,
"status": "running",
"ref": "main",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"tag": false,
"yaml_errors": null,
"user": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2016-08-11T11:28:34.085Z",
"updated_at": "2016-08-11T11:32:35.169Z",
"started_at": null,
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null,
"queued_duration": 0.010,
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46",
"name": "Some new pipeline name",
"archived": false
}
