Skip to main content

git-mirror


title: GIT Mirror component

Makes a bare clone and mirrors the result to the destination. Can allow customization during mirroring.

Variables

NamerequiredtypeHints
GITLAB_TOKENoptionalstringIs a GitLab Token
GIT_SSH_KEYoptionalfileIs a SSH Key. Use when there is no token

Setup

Choice 1: Use GitLab Token

  • Add the CI Variable GITLAB_TOKEN as 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_KEY as 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

NameDescriptionDefaultType
------------
custom-scriptCustom script to run in addition to the default mirroring script.string
destinationThe destination repository to mirror to like git@git.example.com:xrow-public/ci-tools.git.string
git-tokenThe token to be used. Provide the variable name.GITLAB_TOKENstring
namegitstring
needsThe jobs that this job depends on.[]array
rulesThe 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
sourceThe source repository to mirror. Like https://gitlab.com/xrow-public/ci-tools.gitstring
ssh-private-keyThe ssh key to be used. Provide the variable name as file.GIT_SSH_KEYstring
stageThe pipeline stage that the jobs belongs to.deploystring