프로젝트 원격 미러 API

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

푸시 미러
은 프로젝트의 리포지토리 설정에서 정의된 “원격 미러”입니다.
원격 미러 API를 사용하여 이러한 미러의 상태를 쿼리하고 수정할 수 있습니다.

보안상의 이유로, API 응답의 url 속성에는 항상 사용자 이름과 비밀번호 정보가 지워집니다.

note
풀 미러
는 이들을 표시하고 업데이트하기 위해
다른 API 엔드포인트를 사용합니다.

프로젝트의 원격 미러 목록

원격 미러와 그 상태의 배열을 반환합니다:

GET /projects/:id/remote_mirrors

예제 요청:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors"

예제 응답:

[
  {
    "enabled": true,
    "id": 101486,
    "auth_method": "ssh_public_key",
    "last_error": null,
    "last_successful_update_at": "2020-01-06T17:32:02.823Z",
    "last_update_at": "2020-01-06T17:32:02.823Z",
    "last_update_started_at": "2020-01-06T17:31:55.864Z",
    "only_protected_branches": true,
    "keep_divergent_refs": true,
    "update_status": "finished",
    "url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
  }
]

단일 프로젝트의 원격 미러 가져오기

원격 미러와 그 상태를 반환합니다:

GET /projects/:id/remote_mirrors/:mirror_id

예제 요청:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"

예제 응답:

{
  "enabled": true,
  "id": 101486,
  "last_error": null,
  "last_successful_update_at": "2020-01-06T17:32:02.823Z",
  "last_update_at": "2020-01-06T17:32:02.823Z",
  "last_update_started_at": "2020-01-06T17:31:55.864Z",
  "only_protected_branches": true,
  "keep_divergent_refs": true,
  "update_status": "finished",
  "url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}

풀 미러 생성

프로젝트 풀 미러링 API를 사용하여 풀 미러를 구성하는 방법을 알아보세요.

푸시 미러 생성

푸시 미러링은 기본적으로 비활성화되어 있습니다. 미러를 생성할 때 선택적 매개변수 enabled를 포함하여 활성화하세요:

POST /projects/:id/remote_mirrors
속성 유형 필수 설명
url 문자열 리포지토리가 미러되는 대상 URL입니다.
enabled 불리언 아니오 미러가 활성화되어 있는지 여부를 결정합니다.
keep_divergent_refs 불리언 아니오 발산된 참조가 건너뛰어지는지 여부를 결정합니다.
only_protected_branches 불리언 아니오 보호된 브랜치만 미러되는지 여부를 결정합니다.
mirror_branch_regex 문자열 아니오 정규 표현식을 포함합니다. 정규 표현식과 일치하는 이름을 가진 브랜치만 미러됩니다. only_protected_branches가 비활성화되어야 합니다. Premium 및 Ultimate만 가능.
auth_method 문자열 아니오 미러 인증 방법을 결정합니다 (ssh_public_key 또는 password).

예제 요청:

curl --request POST --data "url=https://username:token@example.com/gitlab/example.git" \
     --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors"

예제 응답:

{
    "enabled": false,
    "id": 101486,
    "auth_method": "password",
    "last_error": null,
    "last_successful_update_at": null,
    "last_update_at": null,
    "last_update_started_at": null,
    "only_protected_branches": false,
    "keep_divergent_refs": false,
    "update_status": "none",
    "url": "https://*****:*****@example.com/gitlab/example.git"
}

원격 미러의 속성 업데이트

원격 미러를 켜거나 끄고, 어떤 유형의 브랜치가 미러링될지 변경하세요:

PUT /projects/:id/remote_mirrors/:mirror_id
속성 유형 필수 설명
mirror_id Integer 원격 미러 ID입니다.
enabled Boolean 아니오 미러가 활성화되어 있는지 여부를 결정합니다.
keep_divergent_refs Boolean 아니오 분기된 참조가 건너뛰어지는지 여부를 결정합니다.
only_protected_branches Boolean 아니오 보호된 브랜치만 미러링되는지 여부를 결정합니다.
mirror_branch_regex String 아니오 정규 표현식과 일치하는 이름을 가진 브랜치만 미러링됩니다. only_protected_branches가 활성화된 경우에는 작동하지 않습니다. Premium 및 Ultimate 전용입니다.
auth_method String 아니오 미러 인증 방법(ssh_public_key 또는 password)을 결정합니다.

예제 요청:

curl --request PUT --data "enabled=false" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"

예제 응답:

{
    "enabled": false,
    "id": 101486,
    "auth_method": "password",
    "last_error": null,
    "last_successful_update_at": "2020-01-06T17:32:02.823Z",
    "last_update_at": "2020-01-06T17:32:02.823Z",
    "last_update_started_at": "2020-01-06T17:31:55.864Z",
    "only_protected_branches": true,
    "keep_divergent_refs": true,
    "update_status": "finished",
    "url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}

강제 푸시 미러 업데이트

푸시 미러에 대한 업데이트를 강제로 적용하세요.

POST /projects/:id/remote_mirrors/:mirror_id/sync

지원하는 속성:

속성 유형 필수 설명
id integer 또는 string 프로젝트의 ID 또는 URL로 인코딩된 경로.
mirror_id Integer 원격 미러 ID입니다.

성공 시, 204를 반환합니다.

예제 요청:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486/sync"

예제 응답:

HTTP 응답 코드 204와 함께 빈 응답.

원격 미러 삭제

원격 미러를 삭제합니다.

DELETE /projects/:id/remote_mirrors/:mirror_id
속성 유형 필수 설명
mirror_id Integer 원격 미러 ID입니다.

예제 요청:

curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"