Variables unavailable when running a TAG build

Viewed 26

I have a CI pipeline in Gitlab (relevant part only):

default:
    image: docker:latest

variables:
    DOCKER_APP_TAG: ${REGISTRY_URL}/${APP_NAME}:${CI_COMMIT_SHORT_SHA}

stages:
    - build

.config:
    only:
        - branches
        - merge_requests
        - tags
    except:
        - triggers
    tags:
        - prod

build-app:
    extends: .config
    stage: build
    script:
        - docker build --target production -t ${DOCKER_APP_TAG} -f ${CI_PROJECT_DIR}/etc/node/Dockerfile .

When I build from a branch (i.e. push to main branch) everything works well. The docker build command is ran with the proper value available in S{DOCKER_APP_TAG}.
However after I create a TAG in GitLab (and a release), the build on this GitLab TAG fails at the docker build ... line complaining that the docker tag is not valid:

invalid argument "/:e5dc27fd" for "-t, --tag" flag: invalid reference format

The variables ${REGISTRY_URL} and ${APP_NAME} are not expanded. I have checked GitLab docs and the only limitations I see is if I was running in a service. But it is not the case.
What am I missing to expand properly the variables even with tag builds?

0 Answers
Related