Import API
GitHub나 Bitbucket Server에서 리포지터리를 가져오기 위해 Import API를 사용하세요.
GitHub에서 리포지터리 가져오기
- GitLab 15.8에서 도입되었으며, GitLab은 이제
target_namespace
에 지정된 이름 공간이나 그룹 이름이 없는 경우 자동으로 이름 공간이나 그룹을 생성하지 않습니다. 또한, 이름 공간 또는 그룹 이름이 이미 사용 중이거나target_namespace
가 비어 있으면 더 이상 사용자의 개인 이름 공간을 기본값으로 사용하지 않습니다.- GitLab 16.0에서 Maintainer 역할이 개발자 역할 대신 도입되었으며, GitLab 15.11.1 및 GitLab 15.10.5로 백포트되었습니다.
optional_stages
의collaborators_import
키는 GitLab 16.0에서 도입되었습니다.- 피처 플래그
github_import_extended_events
가 GitLab 16.8에서 도입되었습니다. 기본적으로 비활성화되어 있습니다. 이 플래그는 가져오기의 성능을 향상시키지만single_endpoint_issue_events_import
옵션 단계를 비활성화합니다.- 피처 플래그
github_import_extended_events
가 GitLab 16.9에서 GitLab.com 및 자체 호스팅에서 활성화되었습니다.
API를 사용하여 GitHub에서 프로젝트를 GitLab으로 가져옵니다.
전제 조건:
- GitHub 가져오기 프리퀘니시트.
-
target_namespace
에 설정된 이름 공간이 있어야 합니다. - 이름 공간은 사용자 이름 공간이거나 적어도 Maintainer 역할을 가진 기존 그룹이어야 합니다.
POST /import/github
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
personal_access_token
| string | 예 | GitHub 개인 액세스 토큰 |
repo_id
| integer | 예 | GitHub 리포지터리 ID |
new_name
| string | 아니오 | 새 프로젝트의 이름. 새 경로로도 사용되므로 특수 문자로 시작하거나 끝나면 안 되며 연속된 특수 문자를 포함해서는 안 됩니다. |
target_namespace
| string | 예 | 리포지터리를 가져올 이름 공간. /namespace/subgroup 와 같이 하위 그룹을 지원합니다. GitLab 15.8 이상부터 비어 있으면 안 됩니다.
|
github_hostname
| string | 아니오 | 사용자 정의 GitHub Enterprise 호스트 이름. GitHub.com의 경우 설정하지 마십시오. |
optional_stages
| object | 아니오 | 추가적으로 가져올 항목. GitLab 15.5에서 도입되었습니다. |
timeout_strategy
| string | 아니오 | 가져오기 시간 초과 처리 전략. optimistic (가져오기의 다음 단계 계속) 또는 pessimistic (즉시 실패)의 유효한 값입니다. 기본값은 pessimistic 입니다. GitLab 16.5에서 도입되었습니다.
|
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": {
"single_endpoint_issue_events_import": true,
"single_endpoint_notes_import": true,
"attachments_import": true,
"collaborators_import": true
}
}'
다음 키는 optional_stages
에서 사용할 수 있습니다:
- 이슈 및 풀 리퀘스트 이벤트 가져오기를 위한
single_endpoint_issue_events_import
.github_import_extended_events
피처 플래그가 활성화되면 이 옵션 단계를 사용할 수 없습니다. - 대체 및 보다 철저한 주석 가져오기를 위한
single_endpoint_notes_import
. - 마크다운 첨부 파일 가져오기를 위한
attachments_import
. - 외부 협력자가 아닌 직접적인 리포지터리 협력자 가져오기를 위한
collaborators_import
.
더 많은 정보는 추가 가져올 항목 선택을 참조하세요.
예시 응답:
{
"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를 통해 공개 프로젝트 가져오기
- GitLab 15.7에서 도입되었으며, 프로젝트는 어떠한 경우에도 봇 사용자 이름 공간에 가져오지 않습니다. 봇 사용자의 이름 공간에 가져온 프로젝트는 유효한 토큰을 가진 사용자에 의해 삭제할 수 없어 보안 위험을 표현했습니다.
API를 사용하여 GitHub에서 GitLab으로 프로젝트를 가져올 때 그룹 액세스 토큰을 사용하는 경우:
- GitLab 프로젝트는 원래 프로젝트의 가시성 설정을 상속합니다. 결과적으로 원래 프로젝트가 공개적인 경우 프로젝트는 공개적으로 접근 가능합니다.
-
path
또는target_namespace
가 존재하지 않으면 프로젝트 가져오기가 실패합니다.
GitHub 프로젝트 가져오기 취소
- GitLab 15.5에서 도입되었습니다.
API를 사용하여 진행 중인 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 스니펫으로 가져오기
- GitLab 15.8에서
github_import_gists
라는 플래그를 사용하여 도입되었습니다. 기본값은 비활성화되어 있습니다. GitLab.com에서 활성화됩니다.- GitLab 15.10에서 Self-managed에서 활성화됩니다.
- GitLab 15.11에서 GA(일반 사용 가능)됩니다. 피처 플래그
github_import_gists
가 제거되었습니다.
개인 GitHub gist(최대 10개의 파일 포함)를 개인 GitLab 스니펫으로 가져오기 위해 GitLab API를 사용할 수 있습니다. 10개 이상의 파일이 있는 GitHub gists는 건너뜁니다. 이러한 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에서 리포지터리 가져오기
API를 사용하여 Bitbucket Server에서 프로젝트를 GitLab으로 가져옵니다.
Bitbucket 프로젝트 키는 Bitbucket에서 리포지터리를 찾을 때만 사용됩니다.
원하는 경우 리포지터리를 GitLab 그룹으로 가져오려면 target_namespace
를 지정해야 합니다.
target_namespace
를 지정하지 않으면 프로젝트는 개인 사용자 네임스페이스로 가져옵니다.
전제 조건:
- 자세한 정보는 Bitbucket Server 가져오기를 위한 전제 조건을 참조하십시오.
POST /import/bitbucket_server
속성 | 유형 | 필수 여부 | 설명 |
---|---|---|---|
bitbucket_server_url
| string | 예 | Bitbucket Server URL |
bitbucket_server_username
| string | 예 | Bitbucket Server 사용자 이름 |
personal_access_token
| string | 예 | Bitbucket Server 개인 액세스 토큰/비밀번호 |
bitbucket_server_project
| string | 예 | Bitbucket 프로젝트 키 |
bitbucket_server_repo
| string | 예 | Bitbucket 리포지터리 이름 |
new_name
| string | 아니요 | 새 프로젝트의 이름. 특수 문자로 시작하거나 끝날 수 없으며 연속된 특수 문자를 포함해서는 안 됩니다. GitLab 15.1과 GitLab 16.9 사이에서는 프로젝트 경로가 Bitbucket에서 복사되었습니다. GitLab 16.10에서는 행동이 원래대로 변경되었습니다. |
target_namespace
| string | 아니요 | 리포지터리를 가져올 네임스페이스. /namespace/subgroup 와 같은 하위 그룹을 지원합니다.
|
timeout_strategy
| string | 아니요 | 가져오기 시간 초과 처리 전략. optimistic (가져오기의 다음 단계 진행) 또는 pessimistic (즉시 실패)의 유효한 값입니다. 기본값은 pessimistic 입니다. GitLab 16.5에서 도입되었습니다.
|
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"
}'