Hello All,
We need to mirror one Bit bucket repository to GitLab. Is it possible to do this??
If so please let us know the process to do it in Bit bucket cloud version.
If you have a Premium subscription with GitLab, I see in their documentation that they offer a pull mirroring functionality from repositories that aren't hosted in GitLab:
If you don't have a Premium GitLab subscription, there are other ways to set this up:
If you make a clone of the Bitbucket Cloud repo on your machine with the --mirror option, you have a copy of the repo with all branches:
git clone --mirror <bitbucket_repo_url>
You can then navigate to the directory of the mirror clone and push to an empty GitLab repo:
git push --mirror <gitlab_repo_url>
In order to update the mirrored repository in GitLab, you can run the following commands in the directory of the mirror clone
git fetch -p origin
git push --mirror <gitlab_repo_url>
You could write a script that performs these operations (fetch and push) and schedule it to run periodically.
Another option is to use Bitbucket Pipelines to automate this process and run a pipelines build every time there is a push to the repo. You could use a bitbucket-pipelines.yml file similar to that one:
image: atlassian/default-image:4
pipelines:
default:
- step:
clone:
enabled: false
name: 'Mirror repository'
script:
- git clone --mirror ${BITBUCKET_GIT_SSH_ORIGIN}
- cd ${BITBUCKET_REPO_SLUG}.git
- git push --mirror <gitlab_repo_url>
Such a pipeline will run on every push to the repo, but you can also use a custom pipeline and schedule it to run at certain times/days.
You will need to set up authentication details to push to the GitLab repo. If you want to use SSH keys, you can set up SSH keys in Pipelines, and upload the public key to a GitLab account that has write access to that GitLab repo:
You could also check what other authentication methods GitLab provides, e.g. tokens, and use HTTPS Basic Authentication with a token, instead of SSH.
If you have any questions, please feel free to reach out.
Kind regards,
Theodora
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.