가져오기 API
GitLab v19.5Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
요약
이 기능의 사용 가능 여부는 기능 플래그로 제어됩니다. 이 API를 사용하여 외부 소스에서 리포지터리를 가져옵니다. 개인 네임스페이스로 프로젝트를 가져올 때는 사용자 기여 매핑이 지원되지 않습니다. GitHub의 리포지터리를 GitLab으로 가져옵니다.
히스토리
- 개인 네임스페이스로 가져올 때 기여를 개인 네임스페이스 소유자에게 재할당하는 기능이 GitLab 18.3에서
user_mapping_to_personal_namespace_owner기능 플래그와 함께 도입되었습니다. 기본값은 비활성화입니다. - 개인 네임스페이스로 가져올 때 기여를 개인 네임스페이스 소유자에게 재할당하는 기능이 GitLab 18.6에서 일반 공급되었습니다. 기능 플래그
user_mapping_to_personal_namespace_owner는 제거되었습니다. - GitLab 19.4에서 새로 구성하는 가져오기에 대해
single_endpoint_notes_import가 항상 활성화되며, 더 이상 비활성화할 수 없습니다. 이전 GitLab 버전에서 구성한 가져오기는 기존에 설정된 값을 유지합니다.
이 기능의 사용 가능 여부는 기능 플래그로 제어됩니다. 자세한 내용은 히스토리를 참고합니다.
이 API를 사용하여 외부 소스에서 리포지터리를 가져옵니다.
개인 네임스페이스로 프로젝트를 가져올 때는 사용자 기여 매핑이 지원되지 않습니다. 개인 네임스페이스로 가져오면 모든 기여가 개인 네임스페이스 소유자에게 할당되며 재할당할 수 없습니다.
GitHub에서 리포지터리 가져오기#
GitHub의 리포지터리를 GitLab으로 가져옵니다.
사전 요구 사항:
- GitHub 가져오기 도구의 사전 요구 사항을 충족해야 합니다.
target_namespace에 지정한 네임스페이스가 존재해야 합니다.- 네임스페이스는 사용자 네임스페이스이거나, Maintainer 또는 Owner 권한을 가진 기존 그룹이어야 합니다.
POST /import/github
| 속성 | 유형 | 필수 | 설명 |
|---|---|---|---|
personal_access_token |
string | 예 | GitHub 개인 액세스 토큰입니다. |
repo_id |
integer | 예 | GitHub 리포지터리 ID 입니다. |
target_namespace |
string | 예 | 리포지터리를 가져올 네임스페이스입니다. /namespace/subgroup과 같은 하위 그룹을 지원합니다. 비워 둘 수 없습니다. |
github_hostname |
string | 아니요 | 사용자 지정 GitHub Enterprise 호스트명입니다. GitHub.com에는 설정하지 않습니다. GitLab 16.5부터 GitLab 17.1 까지는 경로 /api/v3를 포함해야 합니다. |
new_name |
string | 아니요 | 새 프로젝트의 이름입니다. 새 경로로도 사용되므로 특수 문자로 시작하거나 끝날 수 없고, 특수 문자를 연속으로 포함할 수 없습니다. |
optional_stages |
object | 아니요 | 추가로 가져올 항목입니다. |
pagination_limit |
integer | 아니요 | GitHub에 보내는 API 요청당 가져오는 항목 수입니다. 기본값은 페이지당 100개입니다. 대용량 리포지터리에서 프로젝트를 가져올 때는 값을 낮추면 GitHub API 엔드포인트가 500 또는 502 오류를 반환할 위험을 줄일 수 있습니다. 다만 페이지 크기가 작을수록 마이그레이션 시간은 길어집니다. |
timeout_strategy |
string | 아니요 | 가져오기 시간 초과를 처리하는 전략입니다. 유효한 값은 optimistic(가져오기의 다음 Stage로 계속 진행) 또는 pessimistic(즉시 실패)입니다. 기본값은 pessimistic 입니다. |
curl --request POST \
--url "https://gitlab.example.com/api/v4/import/github" \
--header "content-type: application/json" \
--header "Authorization: Bearer <your_access_token>" \
--data '{
"personal_access_token": "aBc123abC12aBc123abC12abC123+_A/c123",
"repo_id": "12345",
"target_namespace": "group/subgroup",
"new_name": "NEW-NAME",
"github_hostname": "https://github.example.com",
"optional_stages": {
"attachments_import": true,
"collaborators_import": true
}
}'
optional_stages에는 다음 키를 사용할 수 있습니다.
attachments_import: Markdown 첨부 파일을 가져옵니다.collaborators_import: 외부 협업자가 아닌 직접 리포지터리 협업자를 가져옵니다.single_endpoint_notes_import: 댓글을 더 온전하게 가져오는 대체 방식이며, GitLab 19.3 이전에서는 선택 사항입니다. GitLab 19.4 이상에서는 새로 구성하는 가져오기에 이 방식이 필수입니다.
자세한 내용은 추가로 가져올 항목 선택을 참고합니다.
응답 예시:
{
"id": 27,
"name": "my-repo",
"full_path": "/root/my-repo",
"full_name": "Administrator / my-repo",
"refs_url": "/root/my-repo/refs",
"import_source": "my-github/repo",
"import_status": "scheduled",
"human_import_status_name": "scheduled",
"provider_link": "/my-github/repo",
"relation_type": null,
"import_warning": null
}
그룹 액세스 토큰으로 API를 통해 공개 프로젝트 가져오기#
그룹 액세스 토큰으로 API를 통해 GitHub의 프로젝트를 GitLab으로 가져오면 다음과 같이 동작합니다.
- GitLab 프로젝트는 원본 프로젝트의 공개 범위 설정을 상속합니다. 따라서 원본 프로젝트가 공개이면 가져온 프로젝트도 공개 상태가 됩니다.
path또는target_namespace가 존재하지 않으면 프로젝트 가져오기가 실패합니다.
GitHub 프로젝트 가져오기 취소#
진행 중인 GitHub 프로젝트 가져오기를 취소합니다.
POST /import/github/cancel
| 속성 | 유형 | 필수 | 설명 |
|---|---|---|---|
project_id |
integer | 예 | GitLab 프로젝트 ID 입니다. |
curl --request POST \
--url "https://gitlab.example.com/api/v4/import/github/cancel" \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data '{
"project_id": 12345
}'
응답 예시:
{
"id": 160,
"name": "my-repo",
"full_path": "/root/my-repo",
"full_name": "Administrator / my-repo",
"import_source": "source/source-repo",
"import_status": "canceled",
"human_import_status_name": "canceled",
"provider_link": "/source/source-repo"
}
다음 상태 코드를 반환합니다.
200 OK: 프로젝트 가져오기가 취소되는 중입니다.400 Bad Request: 프로젝트 가져오기를 취소할 수 없습니다.404 Not Found:project_id에 해당하는 프로젝트가 존재하지 않습니다.
GitHub Gist를 GitLab 스니펫으로 가져오기#
개인 GitHub Gist를 GitLab 스니펫으로 가져옵니다. 파일이 10개 이하인 Gist를 가져올 수 있습니다. 파일이 10개를 넘는 GitHub Gist는 건너뜁니다. 이러한 GitHub Gist는 직접 마이그레이션해야 합니다.
가져오지 못한 Gist가 있으면 가져오지 못한 Gist 목록이 담긴 이메일이 발송됩니다.
POST /import/github/gists
| 속성 | 유형 | 필수 | 설명 |
|---|---|---|---|
personal_access_token |
string | 예 | GitHub 개인 액세스 토큰입니다. |
curl --request POST \
--url "https://gitlab.example.com/api/v4/import/github/gists" \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: <your_gitlab_access_token>" \
--data '{
"personal_access_token": "<your_github_personal_access_token>"
}'
다음 상태 코드를 반환합니다.
202 Accepted: Gist 가져오기가 시작되는 중입니다.401 Unauthorized: 사용자의 GitHub 개인 액세스 토큰이 유효하지 않습니다.422 Unprocessable Entity: Gist 가져오기가 이미 진행 중입니다.429 Too Many Requests: 사용자가 GitHub의 속도 제한을 초과했습니다.
Bitbucket Server에서 리포지터리 가져오기#
히스토리
bitbucket_server_project와bitbucket_server_repo검증이 GitLab 19.1에서 도입되었습니다.
Bitbucket Server의 리포지터리를 GitLab으로 가져옵니다.
Bitbucket 프로젝트 키는 Bitbucket에서 리포지터리를 찾는 데만 사용됩니다.
리포지터리를 GitLab 그룹으로 가져오려면 target_namespace를 지정해야 합니다.
target_namespace를 지정하지 않으면 프로젝트는 개인 사용자 네임스페이스로 가져옵니다.
사전 요구 사항:
- 자세한 내용은 Bitbucket Server 가져오기 도구의 사전 요구 사항을 참고합니다.
POST /import/bitbucket_server
| 속성 | 유형 | 필수 | 설명 |
|---|---|---|---|
bitbucket_server_project |
string | 예 | Bitbucket 프로젝트 키입니다. 영문자, 숫자, 하이픈, 밑줄, 마침표, 공백 문자만 포함할 수 있습니다. 개인 프로젝트 키는 ~로 시작합니다. |
bitbucket_server_repo |
string | 예 | Bitbucket 리포지터리 이름입니다. 영문자, 숫자, 하이픈, 밑줄, 마침표, 공백 문자만 포함할 수 있습니다. |
bitbucket_server_url |
string | 예 | Bitbucket Server URL 입니다. |
bitbucket_server_username |
string | 예 | Bitbucket Server 사용자 이름입니다. |
personal_access_token |
string | 예 | Bitbucket Server 개인 액세스 토큰 또는 비밀번호입니다. |
new_name |
string | 아니요 | 새 프로젝트의 이름입니다. 새 경로로도 사용되므로 특수 문자로 시작하거나 끝날 수 없고, 특수 문자를 연속으로 포함할 수 없습니다. |
target_namespace |
string | 아니요 | 리포지터리를 가져올 네임스페이스입니다. /namespace/subgroup과 같은 하위 그룹을 지원합니다. |
timeout_strategy |
string | 아니요 | 가져오기 시간 초과를 처리하는 전략입니다. 유효한 값은 optimistic(가져오기의 다음 Stage로 계속 진행) 또는 pessimistic(즉시 실패)입니다. 기본값은 pessimistic 입니다. |
curl --request POST \
--url "https://gitlab.example.com/api/v4/import/bitbucket_server" \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data '{
"bitbucket_server_url": "http://bitbucket.example.com",
"bitbucket_server_username": "root",
"personal_access_token": "Nzk4MDcxODY4MDAyOiP8y410zF3tGAyLnHRv/E0+3xYs",
"bitbucket_server_project": "NEW",
"bitbucket_server_repo": "my-repo",
"new_name": "NEW-NAME"
}'
Bitbucket Cloud에서 리포지터리 가져오기#
히스토리
Bitbucket Cloud의 리포지터리를 GitLab으로 가져옵니다.
사전 요구 사항:
- Bitbucket Cloud 가져오기 도구의 사전 요구 사항을 충족해야 합니다.
- 필요한 스코프를 가진 Bitbucket Cloud API 토큰이 있어야 합니다.
POST /import/bitbucket
| 속성 | 유형 | 필수 | 설명 |
|---|---|---|---|
bitbucket_api_token |
string | 예 | Bitbucket Cloud API 토큰입니다. |
bitbucket_email |
string | 예 | Bitbucket Cloud 이메일입니다. |
repo_path |
string | 예 | 리포지터리 경로입니다. |
target_namespace |
string | 예 | 리포지터리를 가져올 네임스페이스입니다. /namespace/subgroup과 같은 하위 그룹을 지원합니다. |
new_name |
string | 아니요 | 새 프로젝트의 이름입니다. 새 경로로도 사용되므로 특수 문자로 시작하거나 끝날 수 없고, 특수 문자를 연속으로 포함할 수 없습니다. |
curl --request POST \
--url "https://gitlab.example.com/api/v4/import/bitbucket" \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data '{
"bitbucket_email": "email@example.com",
"bitbucket_api_token": "your_bitbucket_api_token",
"repo_path": "username/my_project",
"target_namespace": "my_group/my_subgroup",
"new_name": "new_project_name"
}'
Bitbucket Cloud API 토큰 스코프#
Bitbucket Cloud API 토큰으로 인증한다면 해당 토큰에 다음 스코프가 있어야 합니다.
read:repository:bitbucketread:pullrequest:bitbucketread:issue:bitbucketread:wiki:bitbucket