A simple node script to synchronize Bitbucket remote repositories to Gitlab periodically.
It's a unidirectional synchronization from Bitbucket to Gitlab.
By default, the script will run once. If you want it to run periodically (eg. every minutes), you need to add CRONTAB=* * * * *
environment variable.
Script steps:
- Get the name of the repositories to synchronize from
REPOSITORIES=repo1,repo2,...
environment variable. - Check if these names exist on your bitbucket account.
- Get the paths of the repositories on your Gitlab account.
- If there is no Gitlab repository matching the name, the repository will be created.
- Clone (bare) from Bitbucket and push (mirror) to Gitlab.
- Done
Variable | Default | Example |
---|---|---|
BITBUCKET_USERNAME | - | jdoe |
BITBUCKET_PASSWORD | - | xxxx |
BITBUCKET_GROUP_ID | - | johndoe |
GITLAB_TOKEN | - | xxxx |
GITLAB_GROUP_ID | - | 0000000 |
REPOSITORIES | - | rep1,rep2 |
EXEC_CWD | /tmp | /tmp |
CRONTAB | - | * * * * * |
$ docker run -e GITLAB_TOKEN=xxxxx -e REPOSITORIES=git-sync -e CRONTAB="* * * * *" percenuage/get-sync:latest
or
$ docker run --env-file=.env percenuage/get-sync:latest