프로젝트 원격 미러 API

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

프로젝트의 저장소 설정에 정의된 “푸시 미러”를 원격 미러라고 합니다.
원격 미러 API를 사용하여 이러한 미러의 상태를 조회하고 수정할 수 있습니다.

보안상의 이유로 API 응답의 url 속성은 항상 사용자 이름과 암호 정보가 삭제됩니다.

note

Pull mirrors
다른 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"
}

풀 미러 생성

Projects API를 사용하여 풀 미러를 구성하는 방법을 알아보세요.

푸시 미러 생성

  • mirror_branch_regex 필드는 GitLab 15.8에서 도입되었으며 mirror_only_branches_match_regex라는 플래그와 함께 사용됩니다. 기본적으로 비활성화됩니다.
  • GitLab 16.0에서 기본적으로 활성화됩니다.
  • GitLab 16.2에서 일반적으로 사용 가능합니다. mirror_only_branches_match_regex 기능 플래그가 제거되었습니다.
  • auth_method 필드는 GitLab 16.10에서 도입되었습니다.

푸시 미러는 기본적으로 비활성화되어 있습니다. 활성화하려면 미러를 생성할 때 선택적 매개변수 enabled를 포함하십시오:

POST /projects/:id/remote_mirrors
속성 유형 필수 설명
url 문자열 저장소가 미러링되는 대상 URL.
enabled 부울 아니오 미러 활성화 여부를 결정합니다.
keep_divergent_refs 부울 아니오 발산하는 refs를 건너뛰는지 여부를 결정합니다.
only_protected_branches 부울 아니오 보호된 브랜치만 미러링되는지 여부를 결정합니다.
mirror_branch_regex 문자열 아니오 정규식을 포함합니다. 정규식과 일치하는 이름의 브랜치만 미러링됩니다. only_protected_branches가 비활성화되어 있어야 합니다. 프리미엄 및 얼티메이트 전용입니다.
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"
}

원격 미러의 속성 업데이트

  • 필드 auth_method는 GitLab 16.10에서 도입되었습니다.

원격 미러를 켜거나 끄거나 또는 미러링되는 브랜치 유형을 변경합니다.

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가 활성화되어 있으면 작동하지 않습니다. 프리미엄 및 얼티메이트 전용.
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"
}

원격 미러 삭제

  • GitLab 14.10에서 도입되었습니다.

원격 미러를 삭제합니다.

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"