git-mirror
title: GIT Mirror component
Makes a bare clone and mirrors the result to the destination. Can allow customization during mirroring.
Variables
| Name | required | type | Hints |
|---|---|---|---|
| GITLAB_TOKEN | optional | string | Is a GitLab Token |
| GIT_SSH_KEY | optional | file | Is a SSH Key. Use when there is no token |
Setup
Choice 1: Use GitLab Token
- Add the CI Variable
GITLAB_TOKENas string with the access token to the destination repository.
Choice 2: Use SSH Key
- Setup a Deploy Key with access to the destination repository.
- Add the CI Variable
GIT_SSH_KEYas file with the access key to the destination repository.
Usage
- Create GitLab pipeline file
.gitlab-ci.yml:
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/git-mirror@stable
inputs:
source: https://gitlab.com/xrow-public/ci-tools.git
destination: git@git.example.com:xrow-public/ci-tools.git
Inputs
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| custom-script | Custom script to run in addition to the default mirroring script. | string | |
| destination | The destination repository to mirror to like git@git.example.com:xrow-public/ci-tools.git. | string | |
| git-token | The token to be used. Provide the variable name. | GITLAB_TOKEN | string |
| name | git | string | |
| needs | The jobs that this job depends on. | [] | array |
| rules | The rules that this job depends on. | [{"if":"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && ( $CI_PIPELINE_SOURCE == \"push\" \|\| $CI_PIPELINE_SOURCE == \"web\" \|\| $CI_PIPELINE_SOURCE == \"schedule\" )","when":"on_success"},{"when":"never"}] | array |
| source | The source repository to mirror. Like https://gitlab.com/xrow-public/ci-tools.git | string | |
| ssh-private-key | The ssh key to be used. Provide the variable name as file. | GIT_SSH_KEY | string |
| stage | The pipeline stage that the jobs belongs to. | deploy | string |