파이프라인 API

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

파이프라인 페이징

기본적으로 GET 요청은 API 결과가 페이지로 구분되기 때문에 한 번에 20개의 결과를 반환합니다.

페이징에 대해 더 알아보기.

프로젝트 파이프라인 목록

프로젝트에서 파이프라인을 나열합니다. 하위 파이프라인은 결과에 포함되지 않지만 개별적으로 하위 파이프라인을 가져올 수 있습니다.

GET /projects/:id/pipelines
속성 유형 필수 설명
id integer/string 프로젝트의 ID 또는 URL 인코딩된 경로
name string 아니오 지정된 이름의 파이프라인을 반환합니다.
order_by string 아니오 파이프라인을 id, status, ref, updated_at 또는 user_id로 정렬합니다(기본값: id)
ref string 아니오 파이프라인의 ref
scope string 아니오 파이프라인의 범위 중 하나: running, pending, finished, branches, tags
sha string 아니오 파이프라인의 SHA
sort string 아니오 파이프라인을 asc 또는 desc순으로 정렬합니다(기본값: desc)
source string 아니오 GitLab 14.3 이후, 파이프라인이 트리거된 방법 중 하나: 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 string 아니오 파이프라인의 상태 중 하나: created, waiting_for_resource, preparing, pending, running, success, failed, canceled, skipped, manual, scheduled
updated_after datetime 아니오 지정된 날짜 이후에 업데이트된 파이프라인을 반환합니다. ISO 8601 형식으로 예상됨 (2019-03-15T08:00:00Z).
updated_before datetime 아니오 지정된 날짜 이전에 업데이트된 파이프라인을 반환합니다. ISO 8601 형식으로 예상됨 (2019-03-15T08:00:00Z).
username string 아니오 파이프라인을 트리거한 사용자의 사용자 이름
yaml_errors boolean 아니오 잘못된 구성으로 파이프라인을 반환합니다.
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": "빌드 파이프라인",
  "status": "성공",
  "ref": "main",
  "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
  "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
  "tag": false,
  "yaml_errors": null,
  "user": {
    "name": "관리자",
    "username": "root",
    "id": 1,
    "state": "활성",
    "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 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id 정수 파이프라인의 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"
  }
]

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

참고: 이 API 경로는 단위 테스트 보고서 기능의 일부입니다.

GET /projects/:id/pipelines/:pipeline_id/test_report
속성 유형 필수 설명
id 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id 정수 파이프라인의 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": "보안",
      "total_time": 5,
      "total_count": 1,
      "success_count": 1,
      "failed_count": 0,
      "skipped_count": 0,
      "error_count": 0,
      "test_cases": [
        {
          "status": "성공",
          "name": "보안 보고서는 자동 복구 MR을 생성할 수 있습니다",
          "classname": "vulnerability_management_spec",
          "execution_time": 5,
          "system_output": null,
          "stack_trace": null
        }
      ]
    }
  ]
}

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

  • GitLab 14.2에서 소개됨.

참고: 이 API 경로는 단위 테스트 보고서 기능의 일부입니다.

GET /projects/:id/pipelines/:pipeline_id/test_report_summary
속성 타입 필수 설명
id 정수/문자열 프로젝트의 ID 또는 URL-encoded 경로
pipeline_id 정수 파이프라인의 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 문자열 아니오 최신 파이프라인을 확인할 브랜치 또는 태그. 지정되지 않은 경우 기본 브랜치로 설정됩니다.
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"
    }
}

새로운 파이프라인 생성

History
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 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id 정수 파이프라인의 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 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
pipeline_id 정수 파이프라인의 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 정수/문자열 프로젝트의 ID 또는 URL 인코딩된 경로
name 문자열 파이프라인의 새로운 이름
pipeline_id 정수 파이프라인의 ID

샘플 요청:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --data "name=Some new pipeline 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": "Some new pipeline name"
}