| `--src-token` | `$SRC_TOKEN` | GitLab source token (_optional_ if source GitLab group and sub projects have `public` visibility) | _none_ |
| `--src-sync-path` | `$SRC_SYNC_PATH` | GitLab source root group path to synchronize | `to-be-continuous` |
@@ -38,6 +40,8 @@ gitlab-sync.sh \
| `--dest-sync-path` | `$DEST_SYNC_PATH` | GitLab destination root group path to synchronize | guessed from GitLab CI env or `to-be-continuous` |
| `--max-visibility` | `$MAX_VISIBILITY` | maximum visibility of projects in destination group | `$CI_PROJECT_VISIBILITY` (when running in GitLab CI) or `public` |
| `--exclude` | `$EXCLUDE` | coma separated list of project/group path(s) to exclude | _none_ |
| `--insecure` | `$INSECURE` | set to skip TLS check on curl requests | `false` |
| `--update-release` | `$UPDATE_RELEASE` | set to update the releases even if they exists | `false` |
| `--no-group-description` | `$GROUP_DESCRIPTION_DISABLED` | do not synchronise group description | _none_ |
| `--no-project-description` | `$PROJECT_DESCRIPTION_DISABLED` | do not synchronise project description | _none_ |
@@ -56,3 +60,7 @@ Once copied _to be continuous_ to your GitLab server, you shall then schedule a
The script will only require a GitLab token, that shall be configured declaring a `$GITLAB_TOKEN` CI/CD project variable. (`--dest-api` will be implicitly retrieved using predefined `$CI_API_V4_URL`).
You can define a custom alpine image to use by setting `$GITLAB_SYNC_IMAGE` (default to `registry.hub.docker.com/alpine:latest`)
## CI/CD Catalog
To use _to be continuous_ templates as CI/CD Catalog resources on a your GitLab Server, you have to manually activate the _CI/CD Catalog resource_ option in `Settings`/`General`/`Visibility, project features, permissions`.
curl ${INSECURE:+-k}-sSf-H"${DEST_TOKEN:+PRIVATE-TOKEN:$DEST_TOKEN}"-H"Content-Type: application/json"-X POST "$DEST_GITLAB_API/projects/$dest_project_id/releases"\
curl ${INSECURE:+-k}-sSf-H"${DEST_TOKEN:+PRIVATE-TOKEN:$DEST_TOKEN}"-H"Content-Type: application/json"-X PUT "$DEST_GITLAB_API/projects/$dest_project_id/releases/$tag_name"\
# dest project does not exist: create (disable MR and issues as they are cloned projects)
log_info "... destination project not found: create with visibility \\e[33;1m${dest_visibility}\\e[0m"
# TODO enable project as a ci catalog resource
# It seems that the option isn't present in the REST API for now
dest_project_json=$(curl ${INSECURE:+-k}-sSf-H"${DEST_TOKEN:+PRIVATE-TOKEN:$DEST_TOKEN}"-H"Content-Type: application/json"-X POST "$DEST_GITLAB_API/projects"\
# It seems that the option isn't present in the REST API for now
dest_project_json=$(curl ${INSECURE:+-k}-sSf-H"${DEST_TOKEN:+PRIVATE-TOKEN:$DEST_TOKEN}"-H"Content-Type: application/json"-X PUT "$DEST_GITLAB_API/projects/$dest_project_id"\
--data"{
\"name\": $(echo"$src_project_json" | jq .name),
\"visibility\": \"$dest_visibility\"
}")
else
# TODO enable project as a ci catalog resource
# It seems that the option isn't present in the REST API for now
dest_project_json=$(curl ${INSECURE:+-k}-sSf-H"${DEST_TOKEN:+PRIVATE-TOKEN:$DEST_TOKEN}"-H"Content-Type: application/json"-X PUT "$DEST_GITLAB_API/projects/$dest_project_id"\
--data"{
\"name\": $(echo"$src_project_json" | jq .name),
@@ -220,6 +272,11 @@ function sync_project() {
log_info "... protect $src_default_branch branch"
curl ${INSECURE:+-k}-sS-H"${DEST_TOKEN:+PRIVATE-TOKEN:$DEST_TOKEN}"-X POST "$DEST_GITLAB_API/projects/$dest_project_id/protected_branches?name=$src_default_branch"> /dev/null
fi
# 3: sync Releases
curl ${INSECURE:+-k}-sSf-H"${SRC_TOKEN:+PRIVATE-TOKEN:$SRC_TOKEN}""$SRC_GITLAB_API/projects/$src_project_id/releases?per_page=100" | jq -r'.[].tag_name' | while read-r release;do