Bitbucket or GitLab shared runners are pretty slow, and our CI/CD usage is pretty intense. So we decided to host our GitLab instance, as we already manage and operate some for our customers (also known as, eat your own cooking strategy).
Here is how we proceed to preserve the historic of contributions, like pull-requests and their comments, issues and wikis.
Authorize Bitbucket access
First step to import projects from Bitbucket Cloud, you must create a GitLab application in the Access management > OAuth section of Bitbucket settings.
With the right permissions:
Then, you just have to add the key and the secret to the GitLab configuration (/etc/gitlab/gitlab.rb) :
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_providers'] = [
{
"name" => "bitbucket",
"app_id" => "****",
"app_secret" => "****",
"url" => "https://bitbucket.org/"
}
]
Before reconfiguring it, which will restart it taking account of modifications:
gitlab-ctl reconfigure
Migrate your projects
To simplify the migration operation, since the import preserve on going pull-requests and their active comments. You can choose a date/time to migrate the projects, instead of waiting all pull-requests to be merged.
To be sure that there's no modification during the migration, remove the write permissions on Bitbucket. In our case, it's very simple, as we manage access by group of users (Administrators, Maintainers, Developpers, Reporters). We just have to set every groups to read permission in the Access management > User groups of Bitbucket settings:
Put imports in motion, add a project, select import a project tab, choose Bitbucket Cloud:
Here, Bitbucket ask you to confirm the access to your account, listing permissions on it. Then, it let you choose compatible projects (git) to migrate.
If repositories are voluminous, with a lot of historic, the import may take few minutes. In the meantime, create users and/or assign their rights, preferably through groups or directly on projects if you need more granularity.
All that remains is to modify remotes in local git configurations:
# rename the old remote
git remote rename origin bitbucket
# add the new remote
git remote add origin git@hexack.nuajik.io:<group>/<project>.git
# update *all* branches
git branch <branch> -u origin/master
And start to use GitLab, validate merge-requests, add necessary integrations, write your .gitlab-ci.yml, etc.