커밋 API

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

이 API는 리포지터리 커밋에 대해 작동합니다. 커밋에 대한 GitLab-specific information을 자세히 알아보세요.

응답

이 API의 응답에서 일부 날짜 필드는 중복 정보인 것처럼 보일 수 있습니다.

  • created_at 필드는 다른 GitLab API와의 일관성을 위해 존재합니다. 항상 committed_date 필드와 동일합니다.
  • committed_dateauthored_date 필드는 다른 소스에서 생성되며 동일하지 않을 수 있습니다.

리포지터리 커밋 디렉터리

  • GitLab 15.10에서 소개된 작성자별 커밋.

프로젝트의 리포지터리 커밋 디렉터리을 가져옵니다.

GET /projects/:id/repository/commits
속성 유형 필수 설명
id integer/string 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-encoded 경로
ref_name string 아니요 리포지터리 브랜치, 태그 또는 리비전 범위의 이름. 제공되지 않으면 기본 브랜치
since string 아니요 ISO 8601 형식 YYYY-MM-DDTHH:MM:SSZ의 날짜 이후 또는 해당 날짜에 있는 커밋만 반환
until string 아니요 ISO 8601 형식 YYYY-MM-DDTHH:MM:SSZ의 날짜 이전 또는 해당 날짜에 있는 커밋만 반환
path string 아니요 파일 경로
author string 아니요 커밋 작성자에 의해 커밋 검색
all boolean 아니요 리포지터리에서 모든 커밋 검색
with_stats boolean 아니요 각 커밋에 대한 통계를 응답에 추가
first_parent boolean 아니요 Merge 커밋을 볼 때 첫 번째 부모 커밋만 따름
order string 아니요 커밋 순서대로 디렉터리. 가능한 값: default, topo. 기본값은 default이며, 커밋은 시간 역순으로 표시됩니다.
trailers boolean 아니요 각 커밋에 대해 Git trailers를 구문 분석하여 포함
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits"

예시 응답:

[
  {
    "id": "ed899a2f4b50b4370feeea94676502b42383c746",
    "short_id": "ed899a2f4b5",
    "title": "Replace sanitize with escape once",
    "author_name": "Example User",
    "author_email": "user@example.com",
    "authored_date": "2021-09-20T11:50:22.001+00:00",
    "committer_name": "Administrator",
    "committer_email": "admin@example.com",
    "committed_date": "2021-09-20T11:50:22.001+00:00",
    "created_at": "2021-09-20T11:50:22.001+00:00",
    "message": "Replace sanitize with escape once",
    "parent_ids": [
      "6104942438c14ec7bd21c6cd5bd995272b3faff6"
    ],
    "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746",
    "trailers": {},
    "extended_trailers": {}
  },
  {
    "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
    "short_id": "6104942438c",
    "title": "Sanitize for network graph",
    "author_name": "randx",
    "author_email": "user@example.com",
    "committer_name": "ExampleName",
    "committer_email": "user@example.com",
    "created_at": "2021-09-20T09:06:12.201+00:00",
    "message": "Sanitize for network graph\nCc: John Doe <johndoe@gitlab.com>\nCc: Jane Doe <janedoe@gitlab.com>",
    "parent_ids": [
      "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
    ],
    "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746",
    "trailers": { "Cc": "Jane Doe <janedoe@gitlab.com>" },
    "extended_trailers": { "Cc": ["John Doe <johndoe@gitlab.com>", "Jane Doe <janedoe@gitlab.com>"] }
  }
]

여러 파일 및 동작으로 커밋 만들기

JSON 페이로드를 게시하여 커밋 만들기

POST /projects/:id/repository/commits
속성 유형 필수 설명
id integer/string 프로젝트의 ID 또는 URL-encoded path
branch string 커밋할 브랜치의 이름. 새 브랜치를 만드는 경우 start_branch 또는 start_sha 및 선택적으로 start_project를 제공
commit_message string 커밋 메시지
start_branch string 아니요 새 브랜치를 시작하는 브랜치의 이름
start_sha string 아니요 새로운 브랜치를 시작하는 커밋의 SHA
start_project integer/string 아니요 새로운 브랜치를 시작하는 프로젝트의 ID 또는 URL-encoded 경로. 기본값은 id의 값입니다.
actions[] array 일괄로 커밋할 작업 해시 배열. 어떤 속성을 취할 수 있는지에 대한 다음 테이블 참조
author_email string 아니요 커밋 작성자의 이메일 주소 지정
author_name string 아니요 커밋 작성자의 이름 지정
stats boolean 아니요 커밋 통계 포함. 기본값은 true
force boolean 아니요 true일 때 start_branch 또는 start_sha를 기반으로 새로운 커밋으로 대상 브랜치를 덮어쓸 때
actions[] 속성 유형 필수 설명
action string 수행할 동작: create, delete, move, update, 또는 chmod
file_path string 파일의 전체 경로. 예: lib/class.rb
previous_path string 아니요 이동하는 파일의 원래 전체 경로. 예: lib/class1.rb. move 동작에만 해당
content string 아니요 파일 내용. delete, chmod, move를 제외한 모든 동작에 필요함. content를 지정하지 않은 이동 동작은 기존 파일 내용을 유지하며, content의 다른 값은 파일 내용을 덮어씀
encoding string 아니요 text 또는 base64. 기본값은 text
last_commit_id string 아니요 최신 알려진 파일 커밋 ID. 업데이트, 이동 및 삭제 동작에만 해당
execute_filemode boolean 아니요 true/false일 때 파일의 실행 플래그를 활성화/비활성화함. chmod 동작에만 해당
PAYLOAD=$(cat << 'JSON'
{
  "branch": "main",
  "commit_message": "some commit message",
  "actions": [
    {
      "action": "create",
      "file_path": "foo/bar",
      "content": "some content"
    },
    {
      "action": "delete",
      "file_path": "foo/bar2"
    },
    {
      "action": "move",
      "file_path": "foo/bar3",
      "previous_path": "foo/bar4",
      "content": "some content"
    },
    {
      "action": "update",
      "file_path": "foo/bar5",
      "content": "new content"
    },
    {
      "action": "chmod",
      "file_path": "foo/bar5",
      "execute_filemode": true
    }
  ]
}
JSON
)
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data "$PAYLOAD" \
  --url "https://gitlab.example.com/api/v4/projects/1/repository/commits"

예시 응답:

{
  "id": "ed899a2f4b50b4370feeea94676502b42383c746",
  "short_id": "ed899a2f4b5",
  "title": "some commit message",
  "author_name": "Example User",
  "author_email": "user@example.com",
  "committer_name": "Example User",
  "committer_email": "user@example.com",
  "created_at": "2016-09-20T09:26:24.000-07:00",
  "message": "some commit message",
  "parent_ids": [
    "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
  ],
  "committed_date": "2016-09-20T09:26:24.000-07:00",
  "authored_date": "2016-09-20T09:26:24.000-07:00",
  "stats": {
    "additions": 2,
    "deletions": 2,
    "total": 4
  },
  "status": null,
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746"
}

GitLab은 form encoding을 지원합니다. 아래는 form encoding을 사용한 커밋 API의 예시입니다.

curl --request POST \
     --form "branch=main" \
     --form "commit_message=some commit message" \
     --form "start_branch=main" \
     --form "actions[][action]=create" \
     --form "actions[][file_path]=foo/bar" \
     --form "actions[][content]=</path/to/local.file" \
     --form "actions[][action]=delete" \
     --form "actions[][file_path]=foo/bar2" \
     --form "actions[][action]=move" \
     --form "actions[][file_path]=foo/bar3" \
     --form "actions[][previous_path]=foo/bar4" \
     --form "actions[][content]=</path/to/local1.file" \
     --form "actions[][action]=update" \
     --form "actions[][file_path]=foo/bar5" \
     --form "actions[][content]=</path/to/local2.file" \
     --form "actions[][action]=chmod" \
     --form "actions[][file_path]=foo/bar5" \
     --form "actions[][execute_filemode]=true" \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/projects/1/repository/commits"

단일 커밋 가져오기

커밋 해시 또는 브랜치 또는 태그의 이름으로 식별된 특정 커밋을 가져옵니다.

GET /projects/:id/repository/commits/:sha

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시 또는 리포지터리 브랜치 또는 태그의 이름
stats 불리언 아니오 커밋 통계를 포함합니다. 기본값은 true입니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main"

응답 예시:

{
  "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
  "short_id": "6104942438c",
  "title": "Sanitize for network graph",
  "author_name": "randx",
  "author_email": "user@example.com",
  "committer_name": "Dmitriy",
  "committer_email": "user@example.com",
  "created_at": "2021-09-20T09:06:12.300+03:00",
  "message": "Sanitize for network graph",
  "committed_date": "2021-09-20T09:06:12.300+03:00",
  "authored_date": "2021-09-20T09:06:12.420+03:00",
  "parent_ids": [
    "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
  ],
  "last_pipeline" : {
    "id": 8,
    "ref": "main",
    "sha": "2dc6aa325a317eda67812f05600bdf0fcdc70ab0",
    "status": "created"
  },
  "stats": {
    "additions": 15,
    "deletions": 10,
    "total": 25
  },
  "status": "running",
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/6104942438c14ec7bd21c6cd5bd995272b3faff6"
}

커밋이 푸시된 참조 가져오기

커밋이 푸시된 참조(브랜치 또는 태그)를 모두 가져옵니다. 페이지네이션 매개변수 pageper_page를 사용하여 참조 디렉터리을 제한할 수 있습니다.

GET /projects/:id/repository/commits/:sha/refs

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시
type 문자열 아니오 커밋의 범위입니다. 가능한 값은 branch, tag, all입니다. 기본값은 all입니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/5937ac0a7beb003549fc5fd26fc247adbce4a52e/refs?type=all"

응답 예시:

[
  {"type": "branch", "name": "'test'"},
  {"type": "branch", "name": "add-balsamiq-file"},
  {"type": "branch", "name": "wip"},
  {"type": "tag", "name": "v1.1.0"}
 ]

커밋의 일련 번호 가져오기

주어진 커밋에서 부모 링크를 따라 프로젝트에서 커밋의 일련 번호를 가져옵니다.

이 API는 주어진 커밋 SHA에 대해 git rev-list --count 명령과 본질적으로 동일한 기능을 제공합니다.

GET /projects/:id/repository/commits/:sha/sequence

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시
first_parent 부울 아니오 Merge 커밋을 볼 때 첫 번째 부모 커밋 만 따릅니다.

예시 요청:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/5937ac0a7beb003549fc5fd26fc247adbce4a52e/sequence"

예시 응답:

{
  "count": 632
}

커밋 선택하기

주어진 브랜치에 커밋을 선택합니다.

POST /projects/:id/repository/commits/:sha/cherry_pick

매개변수:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시
branch 문자열 브랜치의 이름
dry_run 부울 아니오 어떠한 변경 사항도 커밋하지 않습니다. 기본값은 false입니다. GitLab 13.3에서 도입됨
message 문자열 아니오 새 커밋에 사용할 사용자 정의 커밋 메시지. GitLab 14.0에서 도입됨
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "branch=main" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/cherry_pick"

예시 응답:

{
  "id": "8b090c1b79a14f2bd9e8a738f717824ff53aebad",
  "short_id": "8b090c1b",
  "author_name": "Example User",
  "author_email": "user@example.com",
  "authored_date": "2016-12-12T20:10:39.000+01:00",
  "created_at": "2016-12-12T20:10:39.000+01:00",
  "committer_name": "Administrator",
  "committer_email": "admin@example.com",
  "committed_date": "2016-12-12T20:10:39.000+01:00",
  "title": "Feature added",
  "message": "Feature added\n\nSigned-off-by: Example User <user@example.com>\n",
  "parent_ids": [
    "a738f717824ff53aebad8b090c1b79a14f2bd9e8"
  ],
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}

실패한 체리픽의 경우 응답은 다음과 같이 실패의 문맥을 제공합니다:

{
  "message": "Sorry, we cannot cherry-pick this commit automatically. This commit may already have been cherry-picked, or a more recent commit may have updated some of its content.",
  "error_code": "empty"
}

이 경우 체리픽이 실패한 이유는 변경 내용이 없어서이며, 대상 브랜치에 커밋이 이미 존재할 수 있습니다. 다른 가능한 오류 코드는 conflict입니다. 이는 Merge 충돌이 있었음을 나타냅니다.

dry_run이 활성화되어 있을 때 서버는 체리픽을 시도합니다. 그러나 실제로 결과의 변경 사항을 커밋하지는 않습니다. 체리픽이 깨끗하게 적용되면 API는 200 OK로 응답합니다:

{
  "dry_run": "success"
}

실패한 경우, 실패 사항과 동일한 오류가 표시됩니다.

커밋 되돌리기

주어진 브랜치에서 커밋을 되돌립니다.

POST /projects/:id/repository/commits/:sha/revert

매개변수:

속성 유형 필수 설명
id integer/string yes 프로젝트의 ID 또는 URL 인코딩된 경로
sha string yes 되돌릴 커밋 SHA
branch string yes 대상 브랜치 이름
dry_run boolean no 변경 사항을 커밋하지 않습니다. 기본값은 false입니다. GitLab 13.3에서 도입
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "branch=main" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/a738f717824ff53aebad8b090c1b79a14f2bd9e8/revert"

예시 응답:

{
  "id":"8b090c1b79a14f2bd9e8a738f717824ff53aebad",
  "short_id": "8b090c1b",
  "title":"Revert \"Feature added\"",
  "created_at":"2018-11-08T15:55:26.000Z",
  "parent_ids":["a738f717824ff53aebad8b090c1b79a14f2bd9e8"],
  "message":"Revert \"Feature added\"\n\n커밋 a738f717824ff53aebad8b090c1b79a14f2bd9e8을(를) 되돌립니다",
  "author_name":"관리자",
  "author_email":"admin@example.com",
  "authored_date":"2018-11-08T15:55:26.000Z",
  "committer_name":"관리자",
  "committer_email":"admin@example.com",
  "committed_date":"2018-11-08T15:55:26.000Z",
  "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}

되돌리기에 실패한 경우, 응답에서 실패에 대한 컨텍스트를 제공합니다:

{
  "message": "죄송합니다. 이 커밋을 자동으로 되돌릴 수 없습니다. 해당 커밋이 이미 되돌려졌거나 더 최근의 커밋이 그 내용을 업데이트한 경우일 수 있습니다.",
  "error_code": "conflict"
}

이 경우, 되돌리기가 실패한 이유는 시도한 되돌리기가 Merge 충돌을 생성했기 때문입니다. 다른 가능한 오류 코드는 empty이며, 이는 변경 세트가 비어 있어 이미 되돌려진 사항일 가능성이 높습니다.

dry_run이 활성화된 경우, 서버는 되돌림을 시도하지만 실제로 변경 사항을 커밋하지는 않습니다. 되돌림이 깨끗하게 적용되면 API는 200 OK로 응답합니다:

{
  "dry_run": "success"
}

실패할 경우, 실패 사항에 대한 오류가 표시됩니다. 이는 dry run이 없는 실패와 정확히 동일합니다.

커밋의 차이 가져오기

프로젝트에서 커밋의 차이를 가져옵니다.

GET /projects/:id/repository/commits/:sha/diff

매개변수:

속성 유형 필수 설명
id integer/string yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string yes 리포지터리 브랜치 또는 태그의 커밋 해시 또는 이름
unidiff boolean no 통합된 diff 형식으로 차이 표시하도록 함. 기본값은 false입니다. GitLab 16.5에서 도입됨.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/diff"

예시 응답:

[
  {
    "diff": "@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files",
    "new_path": "doc/update/5.4-to-6.0.md",
    "old_path": "doc/update/5.4-to-6.0.md",
    "a_mode": null,
    "b_mode": "100644",
    "new_file": false,
    "renamed_file": false,
    "deleted_file": false
  }
]

커밋의 댓글 가져오기

프로젝트에서 커밋의 댓글을 가져옵니다.

GET /projects/:id/repository/commits/:sha/comments

매개변수:

속성 유형 필수 설명
id integer/string yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha string yes 리포지터리 브랜치 또는 태그의 커밋 해시 또는 이름
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/comments"

예시 응답:

[
  {
    "note": "이 코드 정말 좋네요",
    "author": {
      "id": 11,
      "username": "admin",
      "email": "admin@local.host",
      "name": "관리자",
      "state": "active",
      "created_at": "2014-03-06T08:17:35.000Z"
    }
  }
]

커밋에 댓글 게시

커밋에 댓글을 추가합니다.

특정 파일의 특정 라인에 댓글을 게시하려면 전체 커밋 SHA, path, line, 그리고 line_typenew여야 합니다.

다음 중 하나 이상의 경우가 해당되면 댓글은 마지막 커밋 뒤에 추가됩니다:

  • sha 대신 브랜치 또는 태그이고 line 또는 path가 잘못된 경우
  • 라인 번호가 잘못된 경우(존재하지 않음)
  • 경로가 잘못된 경우(존재하지 않음)

위의 경우 중 하나에 해당하는 경우, line, line_type, path의 응답이 null로 설정됩니다.

Merge Request에 다른 접근 방법을 보려면 Notes API의 새로운 Merge Request 노트 생성 및 Discussions API의 Merge Request diff에 새로운 스레드 생성을 참조하세요.

POST /projects/:id/repository/commits/:sha/comments
속성 타입 필수 설명
id integer/string 사용자에게 소유된 프로젝트의 ID 또는 URL-인코딩된 경로
sha string 커밋 SHA 또는 리포지터리 브랜치 또는 태그 이름
note string 댓글의 본문
path string 아니요 리포지터리에 상대적인 파일 경로
line integer 아니요 댓글을 추가해야 하는 라인 번호
line_type string 아니요 라인 유형. new 또는 old를 사용합니다.
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "note=Nice picture\!" \
  --form "path=README.md" \
  --form "line=11" \
  --form "line_type=new" \
  --url "https://gitlab.example.com/api/v4/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/comments"

예시 응답:

{
   "author" : {
      "web_url" : "https://gitlab.example.com/janedoe",
      "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
      "username" : "janedoe",
      "state" : "active",
      "name" : "Jane Doe",
      "id" : 28
   },
   "created_at" : "2016-01-19T09:44:55.600Z",
   "line_type" : "new",
   "path" : "README.md",
   "line" : 11,
   "note" : "Nice picture!"
}

커밋 토론 가져오기

프로젝트의 커밋에서 토론을 가져옵니다.

GET /projects/:id/repository/commits/:sha/discussions

매개변수:

속성 타입 필수 설명
id integer/string 사용자에게 소유된 프로젝트의 ID 또는 URL-인코딩된 경로
sha string 커밋 해시 또는 리포지터리 브랜치 또는 태그 이름
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/4604744a1c64de00ff62e1e8a6766919923d2b41/discussions"

예제 응답:

[
  {
    "id": "4604744a1c64de00ff62e1e8a6766919923d2b41",
    "individual_note": true,
    "notes": [
      {
        "id": 334686748,
        "type": null,
        "body": "Nice piece of code!",
        "attachment": null,
        "author" : {
          "id" : 28,
          "name" : "Jane Doe",
          "username" : "janedoe",
          "web_url" : "https://gitlab.example.com/janedoe",
          "state" : "active",
          "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png"
        },
        "created_at": "2020-04-30T18:48:11.432Z",
        "updated_at": "2020-04-30T18:48:11.432Z",
        "system": false,
        "noteable_id": null,
        "noteable_type": "Commit",
        "resolvable": false,
        "confidential": null,
        "noteable_iid": null,
        "commands_changes": {}
      }
    ]
  }
]

커밋 상태

GitLab에서 사용할 커밋 상태 API입니다.

커밋의 상태 나열

프로젝트의 커밋 상태를 나열합니다. 페이지네이션 매개변수 pageper_page는 참조 디렉터리을 제한하는 데 사용할 수 있습니다.

GET /projects/:id/repository/commits/:sha/statuses
속성 타입 필수 설명
id integer/string 사용자에게 소유된 프로젝트의 ID 또는 URL-인코딩된 경로
sha string 커밋 SHA
ref string 아니요 리포지터리 브랜치 또는 태그 이름 또는 지정되지 않은 경우 기본 브랜치
stage string 아니요 빌드 단계별로 필터링합니다. 예: test
name string 아니요 작업 이름별로 필터링합니다. 예: bundler:audit
all boolean 아니요 최신 것뿐만 아니라 모든 상태를 반환합니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/statuses"

예제 응답:

[
   ...
   
   {
      "status" : "pending",
      "created_at" : "2016-01-19T08:40:25.934Z",
      "started_at" : null,
      "name" : "bundler:audit",
      "allow_failure" : true,
      "author" : {
         "username" : "janedoe",
         "state" : "active",
         "web_url" : "https://gitlab.example.com/janedoe",
         "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
         "id" : 28,
         "name" : "Jane Doe"
      },
      "description" : null,
      "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
      "target_url" : "https://gitlab.example.com/janedoe/gitlab-foss/builds/91",
      "finished_at" : null,
      "id" : 91,
      "ref" : "main"
   },
   {
      "started_at" : null,
      "name" : "test",
      "allow_failure" : false,
      "status" : "pending",
      "created_at" : "2016-01-19T08:40:25.832Z",
      "target_url" : "https://gitlab.example.com/janedoe/gitlab-foss/builds/90",
      "id" : 90,
      "finished_at" : null,
      "ref" : "main",
      "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
      "author" : {
         "id" : 28,
         "name" : "Jane Doe",
         "username" : "janedoe",
         "web_url" : "https://gitlab.example.com/janedoe",
         "state" : "active",
         "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png"
      },
      "description" : null
   },
   
   ...
]

커밋의 파이프라인 상태 설정

커밋의 파이프라인 상태를 추가하거나 업데이트합니다. 커밋이 Merge Request과 연관된 경우, API 호출은 Merge Request의 소스 브랜치에 대상 커밋을 지정해야 합니다.

POST /projects/:id/statuses/:sha
속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 SHA
state 문자열 상태값. pending, running, success, failed, canceled 중 하나일 수 있음
ref 문자열 아니오 상태가 참조하는 ref (브랜치 또는 태그)
name 또는 context 문자열 아니오 다른 시스템의 상태와 구분하기 위한 레이블. 기본값은 default
target_url 문자열 아니오 이 상태와 연결할 대상 URL
description 문자열 아니오 상태의 간단한 설명
coverage 부동소수 아니오 총 코드 커버리지
pipeline_id 정수 아니오 상태를 설정하기 위한 파이프라인의 ID. 동일한 SHA에서 여러 파이프라인의 경우 사용
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success"

예시 응답:

{
   "author" : {
      "web_url" : "https://gitlab.example.com/janedoe",
      "name" : "Jane Doe",
      "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
      "username" : "janedoe",
      "state" : "active",
      "id" : 28
   },
   "name" : "default",
   "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
   "status" : "success",
   "coverage": 100.0,
   "description" : null,
   "id" : 93,
   "target_url" : null,
   "ref" : null,
   "started_at" : null,
   "created_at" : "2016-01-19T09:05:50.355Z",
   "allow_failure" : false,
   "finished_at" : "2016-01-19T09:05:50.365Z"
}

커밋과 관련된 Merge Request 디렉터리 가져오기

특정 커밋을 처음으로 소개한 Merge Request에 대한 정보를 반환합니다.

GET /projects/:id/repository/commits/:sha/merge_requests
속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 SHA
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/af5b13261899fb2c0db30abdd0af8b07cb44fdc5/merge_requests"

예시 응답:

[
   {
      "id":45,
      "iid":1,
      "project_id":35,
      "title":"새 파일 추가",
      "description":"",
      "state":"opened",
      "created_at":"2018-03-26T17:26:30.916Z",
      "updated_at":"2018-03-26T17:26:30.916Z",
      "target_branch":"main",
      "source_branch":"test-branch",
      "upvotes":0,
      "downvotes":0,
      "author" : {
        "web_url" : "https://gitlab.example.com/janedoe",
        "name" : "Jane Doe",
        "avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/jane-doe-400-400.png",
        "username" : "janedoe",
        "state" : "active",
        "id" : 28
      },
      "assignee":null,
      "source_project_id":35,
      "target_project_id":35,
      "labels":[ ],
      "draft":false,
      "work_in_progress":false,
      "milestone":null,
      "merge_when_pipeline_succeeds":false,
      "merge_status":"can_be_merged",
      "sha":"af5b13261899fb2c0db30abdd0af8b07cb44fdc5",
      "merge_commit_sha":null,
      "squash_commit_sha":null,
      "user_notes_count":0,
      "discussion_locked":null,
      "should_remove_source_branch":null,
      "force_remove_source_branch":false,
      "web_url":"https://gitlab.example.com/root/test-project/merge_requests/1",
      "time_stats":{
         "time_estimate":0,
         "total_time_spent":0,
         "human_time_estimate":null,
         "human_total_time_spent":null
      }
   }
]

커밋의 GPG 서명 가져오기

서명된 경우, 커밋으로부터 GPG 서명을 가져옵니다. 서명되지 않은 커밋의 경우, 404 응답이 됩니다.

GET /projects/:id/repository/commits/:sha/signature

파라미터:

속성 유형 필수 설명
id 정수/문자열 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로
sha 문자열 커밋 해시 또는 리포지터리 브랜치 또는 태그 이름
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/repository/commits/da738facbc19eb2fc2cef57c49be0e6038570352/signature"

커밋이 GPG로 서명된 경우 예시 응답:

{
  "signature_type": "PGP",
  "verification_status": "verified",
  "gpg_key_id": 1,
  "gpg_key_primary_keyid": "8254AAB3FBD54AC9",
  "gpg_key_user_name": "John Doe",
  "gpg_key_user_email": "johndoe@example.com",
  "gpg_key_subkey_id": null,
  "commit_source": "gitaly"
}

커밋이 X.509으로 서명된 경우 예시 응답:

{
  "signature_type": "X509",
  "verification_status": "unverified",
  "x509_certificate": {
    "id": 1,
    "subject": "CN=gitlab@example.org,OU=Example,O=World",
    "subject_key_identifier": "BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC:BC",
    "email": "gitlab@example.org",
    "serial_number": 278969561018901340486471282831158785578,
    "certificate_status": "good",
    "x509_issuer": {
      "id": 1,
      "subject": "CN=PKI,OU=Example,O=World",
      "subject_key_identifier": "AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB:AB",
      "crl_url": "http://example.com/pki.crl"
    }
  },
  "commit_source": "gitaly"
}

커밋이 서명되지 않은 경우 예시 응답:

{
  "message": "404 GPG Signature Not Found"
}