Mirroring your internal CFMM git project on gitlab.com allows you to use gitlab.com pipeline runners and to share resulting artifacts with gitlab.com users. However generally migrating the entire project to https://gitlab.com/cfmm will be a better option.
These instructions apply to GitLab version 12.8.
Set up mirroring
-
Create an empty repo on gitlab.com. Note its URL, e.g. https://gitlab.com/cfmm/proj1
.
-
In your internal CFMM git project (e.g. https://git.cfmm.uwo.ca/myusername/proj1):
-
Navigate to Settings -> Repository
. Expand the Mirroring Repositories
section.
-
URL: ssh://gitlab.com/cfmm/proj1.git
, where cfmm/proj1
should be replaced with the location of the project form previous step.
-
Mirror direction: Push
. (i.e. you’re pushing from this repo to the gitlab.com repo)
-
Authentication method: SSH Public Key
.
-
Click on Mirror repository
. An entry appears in a table below, with the URL you entered. Click the Copy SSH public key
icon to put it in your clipboard. For more details, see gitlab documentation.
- In your gitlab.com project:
-
Navigate to Settings -> CI/CD
. Expand the Deploy Keys
section.
-
In the Key
field, paste the public key you copied in the previous section when you configured repository mirroring. Put something descriptive as a name, e.g. git.cfmm.uwo.ca mirroring key
. Make sure you check the Write access allowed
checkbox, then Add
.
- In your intenal CFMM git project:
-
After a minute or so, the gitlab.com project should be synchronized with the internal CFMM git project.
-
If you’re setting up CI/CD pipelines, and they will only be running on the gitlab.com project, you should turn off CI/CD on the git.cfmm.uwo.ca project:
-
Navigate to Settings -> General
. Expand the Visibility, project features, permissions
section.
-
Toggle off the Pipelines
section.
Set up a CI pipeline task
This is supplemental documentation to the extensive Gitlab documentation section on CI and pipelines. It explains how a pipeline on gitlab.com will be able to clone private repositories on git.cfmm.uwo.ca (e.g. myuser/myproject1
) using deploy tokens.
- Create a
Deploy Token
in myuser/myproject1
on git.cfmm.uwo.ca which you want to clone from gitlab.com
-
Navigate to Settings -> Repository
. Expand the Deploy Tokens
section.
-
Give a token a descriptive name, or just put the URL of the gitlab.com repo which will be using it.
-
Choose a descriptive username, e.g. gitlab-com-token
.
-
Make sure to check read_repository
to grant read-only access.
-
Save the password that appears. Also note that this is the one and only time you’ll ever see it. If you lose it, you’ll need to recreate the token.
- Save that password into a variable in your gitlab.com project which will run the pipeline:
-
Navigate to Settings -> CI/CD
. Expand the Variables
section.
-
Add a variable with a descriptive name, e.g. token_password_myuser_myproject1
. Toggle the Masked
button to ensure that it is not displayed in plaintext in pipeline job logs.
-
You can now clone myuser/myproject1
on git.cfmm.uwo.ca from gitlab.com by putting the following in your pipeline script. Note that you’re using the variable name and the token username from previous steps, they have to match.
git clone https://gitlab-com-token:${token_password_myuser_myproject1}@git.cfmm.uwo.ca/myuser/myproject1.git