파이프라인 API

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-Managed, GitLab Dedicated

파이프라인 페이지네이션

기본적으로 GET 요청은 API 결과가 페이지별로 20개씩 반환됩니다.

자세한 내용은 페이지네이션을 참조하세요.

프로젝트 파이프라인 디렉터리

프로젝트 내 파이프라인을 나열합니다.

기본적으로 하위 파이프라인은 결과에 포함되지 않습니다. 하위 파이프라인을 반환하려면 sourceparent_pipeline로 설정하세요.

GET /projects/:id/pipelines
속성 유형 필수 설명
id 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
name 문자열 아니오 지정된 이름의 파이프라인 반환
order_by 문자열 아니오 파이프라인 정렬 기준: id, status, ref, updated_at, user_id (기본값: id)
ref 문자열 아니오 파이프라인의 ref
scope 문자열 아니오 파이프라인의 범위: running, pending, finished, branches, tags 중 하나
sha 문자열 아니오 파이프라인의 SHA
sort 문자열 아니오 파이프라인 정렬 순서: asc 또는 desc (기본값: desc)
source 문자열 아니오 파이프라인 트리거된 방법 반환: api, chat, external, external_pull_request_event, merge_request_event, ondemand_dast_scan, ondemand_dast_validation, parent_pipeline, pipeline, push, schedule, security_orchestration_policy, trigger, web, 또는 webide 중 하나
status 문자열 아니오 파이프라인의 상태: created, waiting_for_resource, preparing, pending, running, success, failed, canceled, skipped, manual, scheduled 중 하나
updated_after 날짜/시간 아니오 지정된 날짜 이후에 업데이트된 파이프라인 반환. ISO 8601 형식으로 입력 (2019-03-15T08:00:00Z)
updated_before 날짜/시간 아니오 지정된 날짜 이전에 업데이트된 파이프라인 반환. ISO 8601 형식으로 입력 (2019-03-15T08:00:00Z)
username 문자열 아니오 파이프라인을 트리거한 사용자의 사용자 이름
yaml_errors 부울 아니오 잘못된 구성을 갖는 파이프라인을 반환
curl --header "PRIVATE-TOKEN: <your_access_token>" "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
속성 유형 필수 설명
id 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id 정수 파이프라인의 ID
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"

응답 예시

{
  "id": 46,
  "iid": 11,
  "project_id": 1,
  "name": "Build pipeline",
  "status": "success",
  "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": 123.65,
  "queued_duration": 0.010,
  "coverage": "30.0",
  "web_url": "https://example.com/foo/bar/pipelines/46"
}

파이프라인의 변수 가져오기

GET /projects/:id/pipelines/:pipeline_id/variables
속성 유형 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코드된 경로
pipeline_id integer Yes 파이프라인의 ID
curl --header "PRIVATE-TOKEN: <your_access_token>" "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"
  }
]

파이프라인의 테스트 보고서 가져오기

caution
이 API 경로는 단위 테스트 보고서 기능의 일부입니다.
GET /projects/:id/pipelines/:pipeline_id/test_report
속성 유형 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코드된 경로
pipeline_id integer Yes 파이프라인의 ID

샘플 요청:

curl --header "PRIVATE-TOKEN: <your_access_token>" "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
        }
      ]
    }
  ]
}

파이프라인의 테스트 보고서 요약 가져오기

caution
이 API 경로는 단위 테스트 보고서 기능의 일부입니다.
GET /projects/:id/pipelines/:pipeline_id/test_report_summary
속성 유형 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코드된 경로
pipeline_id integer Yes 파이프라인의 ID

샘플 요청:

curl --header "PRIVATE-TOKEN: <your_access_token>" "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
        }
    ]
}

최신 파이프라인 가져오기

  • 응답의 name은 GitLab 15.11에서 도입되었으며 기본적으로 pipeline_name_in_api라는 플래그로 사용 가능합니다. 기본적으로 비활성화됩니다.
  • 응답의 name은 GitLab 16.3에서 일반적으로 이용 가능하며, 피처 플래그 pipeline_name_in_api가 삭제되었습니다.

특정 ref의 가장 최근 커밋에 대한 최신 파이프라인을 가져옵니다. 커밋에 대한 파이프라인이 없는 경우 403 상태 코드가 반환됩니다.

GET /projects/:id/pipelines/latest
속성 유형 필수 설명
ref string No 최신 파이프라인을 확인할 브랜치 또는 태그. 지정하지 않으면 기본 브랜치로 설정됩니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" "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"
    }
}

새 파이프라인 생성

  • 응답의 iid는 GitLab 14.6에서 도입되었습니다.
POST /projects/:id/pipeline
속성 유형 필수 설명
id integer/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입니다.
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "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"
}

파이프라인에서 작업 다시 시도하기

History

파이프라인에서 실패한 작업 또는 취소된 작업을 다시 시도합니다. 파이프라인에 실패한 작업이나 취소된 작업이 없는 경우, 이 엔드포인트를 호출해도 효과가 없습니다.

POST /projects/:id/pipelines/:pipeline_id/retry
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id integer Yes 파이프라인의 ID
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "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"
}

파이프라인 작업 취소하기

POST /projects/:id/pipelines/:pipeline_id/cancel
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id integer Yes 파이프라인의 ID
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "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"
}

파이프라인 삭제하기

파이프라인을 삭제하면 모든 파이프라인 캐시가 만료되고 빌드, 로그, 아티팩트, 트리거 등과 즉시 관련된 모든 객체가 삭제됩니다. 이 작업은 되돌릴 수 없습니다.

파이프라인을 삭제해도 하위 파이프라인이 자동으로 삭제되지는 않습니다. 자세한 내용은 관련 이슈를 참조하세요.

DELETE /projects/:id/pipelines/:pipeline_id
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id integer Yes 파이프라인의 ID
curl --header "PRIVATE-TOKEN: <your_access_token>" --request "DELETE" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"

파이프라인 메타데이터 업데이트하기

파이프라인의 메타데이터를 업데이트할 수 있습니다. 메타데이터에는 파이프라인의 이름이 포함됩니다.

PUT /projects/:id/pipelines/:pipeline_id/metadata
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로
name string Yes 파이프라인의 새 이름
pipeline_id integer Yes 파이프라인의 ID

샘플 요청:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --data "name=새로운 파이프라인 이름" "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": "새로운 파이프라인 이름"
}