Tool for porting a group of repos from Bitbucket to GitLab
- Ask your GitLab admin to enable importing from Bitbucket Server. If this is not enabled, the REST call to import will return a 403 Forbidden.
- Ensure you have the appropriate permissions for both Bitbucket and GitLab. Admin is required on Bitbucket and Owner is required on GitLab.
- Check the Bitbucket project-level branch permissions to ensure they will not prevent you from changing the repo without a pull request. If there are such permissions, it should be sufficient to add yourself as an exclusion.
-
Create a copy of src/main/resources/application.conf and fill in all the settings with appropriate values. (Note: of course you could modify it in place as well, but take care not to commit the changes, as it will contain your plain text username and access token.) If you place the copy in the root of the repo, it will be ignored by git.
For the access tokens:
-
Create a personal access token in Bitbucket with a scope of Project read (instructions here) and add it to the application.conf as the
source.accessToken
setting. -
Create a personal access token in GitLab with a scope of api (instructions here) and add it to the application.conf as the
target.accessToken
setting.
-
-
If you only wish to port a single repo or some subset of the Bitbucket project, use the
reposToInclude
orreposToExclude
settings:- To port a single repo, set
reposToInclude
to the name of the repo, e.g., "my-repo". - To port only a few repos, set
reposToInclude
to the names of the repos, separated by commas, e.g., "my-repo,my-other-repo". - To port most of the repos in the project, set
reposToExclude
to the names of the repos to ignore, separated by commas.
- To port a single repo, set
-
Execute the
run
task with the system propertyconfig.file
set to the location of your local application.conf:gradlew run -Dconfig.file=path/to/local/application.conf
For example, if the application.conf file was copied to the root of the repo:
gradlew run -Dconfig.file=application.conf
This will port all repos from the specified Bitbucket project unless repos to include/exclude were specified via the
reposToInclude
orreposToExclude
settings.