프로젝트 원격 미러 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"
}

Pull 미러 생성

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

Push 미러 생성

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

POST /projects/:id/remote_mirrors
속성 유형 필수 설명
url String yes 미러링되는 리포지터리의 대상 URL.
enabled Boolean no 미러가 활성화되는지 여부를 결정합니다.
keep_divergent_refs Boolean no 발산 참조가 건너뛰어지는지 여부를 결정합니다.
only_protected_branches Boolean no 보호된 브랜치만 미러링되는지 여부를 결정합니다.
mirror_branch_regex String no 정규 표현식을 포함합니다. 일치하는 이름의 브랜치만 미러링됩니다. only_protected_branches가 비활성화되어야 합니다. premium 및 ultimate 전용입니다.
auth_method String no 미러링 인증 방법을 결정합니다(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 yes 원격 미러 ID.
enabled Boolean no 미러가 활성화되는지 여부를 결정합니다.
keep_divergent_refs Boolean no 발산 참조가 건너뛰어지는지 여부를 결정합니다.
only_protected_branches Boolean no 보호된 브랜치만 미러링되는지 여부를 결정합니다.
mirror_branch_regex String no 정규 표현식을 포함합니다. 일치하는 이름의 브랜치만 미러링됩니다. only_protected_branches가 활성화된 상태에서는 작동하지 않습니다. premium 및 ultimate 전용입니다.
auth_method String no 미러링 인증 방법을 결정합니다(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"
}

Force push mirror update

푸시 미러를 강제로 업데이트합니다.

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

지원되는 속성:

속성 유형 필수여부 설명
id 정수 또는 문자열 프로젝트의 ID 또는 URL 인코딩된 경로.
mirror_id 정수 원격 미러 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 a remote mirror

원격 미러를 삭제합니다.

DELETE /projects/:id/remote_mirrors/:mirror_id
속성 유형 필수여부 설명
mirror_id 정수 원격 미러 ID.

예시 요청:

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