Commit b943e308 authored by Guilhem Bonnefille's avatar Guilhem Bonnefille
Browse files

fix: remove references to legacy shell script

Current gitlab-cp has proven its maturity.

BREAKING CHANGE: no more support for legacy script
parent 048ee6e6
Loading
Loading
Loading
Loading
+0 −96
Original line number Diff line number Diff line
include:
  # $TBC_NAMESPACE is a group variable; can be globally overridden
  - project: '$TBC_NAMESPACE/bash'
    ref: '3.3.0'
    file: '/templates/gitlab-ci-bash.yml'

variables:
  BASH_SHELLCHECK_FILES: "*.sh"
  GITLAB_SYNC_IMAGE: "registry.hub.docker.com/library/alpine:latest"
  # variabilized gitlab-cp image
  GITLABCP_IMAGE: registry.gitlab.com/to-be-continuous/tools/gitlab-cp:latest
  # variabilized sync tool to use (either 'legacy' or 'gitlab-cp')
  SYNC_TOOL: gitlab-cp

stages:
  - build
  - test

sync-tbc-legacy:
  image:
    name: "${GITLAB_SYNC_IMAGE}"
    entrypoint: [""]
  stage: build
  variables:
    # exclude samples group from sync
    EXCLUDE: samples,custom
  before_script:
    - |
      function install_ca_certs() {
        certs=$1
        if [[ -z "$certs" ]]
        then
          return
        fi
        if echo "$certs" >> /etc/ssl/certs/ca-certificates.crt
        then
          echo -e "CA certificates imported in \\e[33;1m/etc/ssl/certs/ca-certificates.crt\\e[0m"
        fi
        if echo "$certs" >> /etc/ssl/cert.pem
        then
          echo -e "CA certificates imported in \\e[33;1m/etc/ssl/cert.pem\\e[0m"
        fi
      }
    - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
    - |
      function maybe_install_pkg() {
        pkg_name="$1"
        cmd_name="${2:-$pkg_name}"
        if ! command -v "$cmd_name" > /dev/null
        then
          echo "[INFO] $pkg_name not found: install..."
          if command -v apt-get > /dev/null
          then
            apt-get install -yq "$pkg_name"
          elif command -v apk > /dev/null
          then
            apk add --no-cache "$pkg_name"
          elif command -v yum > /dev/null
          then
            yum install -yq "$pkg_name"
          elif command -v dnf > /dev/null
          then
            dnf install -yq "$pkg_name"
          elif command -v zypper > /dev/null
          then
            zypper -nq install "$pkg_name"
          else
            echo "[ERROR] ... didn't find any known package manager to install $pkg_name!"
            exit 1
          fi
        fi
      }
    - maybe_install_pkg git
    - maybe_install_pkg curl
    - maybe_install_pkg jq
    - maybe_install_pkg bash
    # done twice because /etc/ssl/certs/ca-certificates.crt is altered during apk add
    # we can't use update-ca-certificates --fresh because $CUSTOM_CA_CERTS can contains several certificates
    - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
  script:
    - bash ${CI_DEBUG_TRACE:+-x} ./gitlab-sync.sh
  rules:
    # disable on gitlab.com
    - if: '$CI_SERVER_HOST == "gitlab.com"'
      when: never
    # disable if $SYNC_TOOL != 'legacy'
    - if: '$SYNC_TOOL != "legacy"'
      when: never
    # allow manual source
    - if: '$CI_PIPELINE_SOURCE == "web"'
    # allow scheduled source
    - if: '$CI_PIPELINE_SOURCE == "schedule"'

sync-tbc-legacy-dryrun:
  extends: sync-tbc-legacy
  script:
    # unset dest GitLab (dryrun)
    - bash ${CI_DEBUG_TRACE:+-x} ./gitlab-sync.sh --dest-api ""
  rules:
    # run only on gitlab.com (to test at least the script correctly crawls tbc projects)
    - if: '$CI_SERVER_HOST == "gitlab.com"'

sync-tbc:
  image:
    name: "$GITLABCP_IMAGE"
@@ -147,9 +54,6 @@ sync-tbc:
    # disable on gitlab.com
    - if: '$CI_SERVER_HOST == "gitlab.com"'
      when: never
    # disable if $SYNC_TOOL != 'gitlab-cp'
    - if: '$SYNC_TOOL != "gitlab-cp"'
      when: never
    # allow manual source
    - if: '$CI_PIPELINE_SOURCE == "web"'
    # allow scheduled source
+0 −7
Original line number Diff line number Diff line
@@ -42,10 +42,3 @@ To use _to be continuous_ templates as CI/CD Catalog resources in your GitLab se
Then you'll have to re-publish a release to make the template appear in the CI/CD Catalog.

:information_source: You may re-run the GitLab Copy CLI tool with the `--update-release` (or `$UPDATE_RELEASE` variable) set to force re-publishig the latest release of each template.

## Legacy `gitlab-sync.sh` script

This project was previously using the `gitlab-sync.sh` script to perform the recursive copy/sync.
It has now been replaced by the [GitLab Copy CLI](https://gitlab.com/to-be-continuous/tools/gitlab-cp) tool that has numerous advantages over it.

Anyhow, the legacy script can still be reactivated by setting the `SYNC_TOOL` CI/CD project variable to `legacy`.

gitlab-sync.sh

deleted100755 → 0
+0 −535

File deleted.

Preview size limit exceeded, changes collapsed.