diff --git a/.gitlab/CI/publish.gitlab-ci.yml b/.gitlab/CI/publish.gitlab-ci.yml index ee010941d0..116313bbff 100644 --- a/.gitlab/CI/publish.gitlab-ci.yml +++ b/.gitlab/CI/publish.gitlab-ci.yml @@ -23,8 +23,8 @@ docker: - export container=docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - | - source "$CI_PROJECT_DIR/.gitlab/scripts/util.sh" - publishdockertag PUBLISH_DOCKER_TAG + source "$CI_PROJECT_DIR/.gitlab/scripts/util.sh"; + publishdockertag; if [ "${PUBLISH_DOCKER_TAG}" != "" ]; then /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/server-cli/Dockerfile --destination "${CI_REGISTRY_IMAGE}/server-cli:${PUBLISH_DOCKER_TAG}" fi diff --git a/.gitlab/scripts/util.sh b/.gitlab/scripts/util.sh index eed00b9b42..46eb227790 100755 --- a/.gitlab/scripts/util.sh +++ b/.gitlab/scripts/util.sh @@ -6,24 +6,23 @@ ### master => "master" ### else => "" publishdockertag () { -# this stores the result in a variable defined by the caller -local -n VAR=$1 -VAR=""; +# this stores the result in PUBLISH_DOCKER_TAG +export PUBLISH_DOCKER_TAG=""; if [[ "${CI_COMMIT_TAG}" =~ ${TAG_REGEX} ]]; then - VAR="${CI_COMMIT_TAG}"; + export PUBLISH_DOCKER_TAG="${CI_COMMIT_TAG}"; return 0; fi if [[ -z "${SCHEDULE_CADENCE}" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then # sanitize check if [[ "${SCHEDULE_CADENCE}" =~ ${TAG_REGEX} ]]; then - VAR="invalid_cadence"; + export PUBLISH_DOCKER_TAG="invalid_cadence"; else - VAR="${SCHEDULE_CADENCE}"; + export PUBLISH_DOCKER_TAG="${SCHEDULE_CADENCE}"; fi return 0; fi if [[ ${CI_COMMIT_BRANCH} == ${CI_DEFAULT_BRANCH} ]]; then - VAR="master"; + export PUBLISH_DOCKER_TAG="master"; return 0; fi } \ No newline at end of file