Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User defined variables in Gitlab CI environment URL empty

I have the following (simplified) gitlab-ci.yml:

variables:
  APP_NAME: "hello-gitlab-ci"
deploy:
  stage: deploy
  script: some-script
environment:
  name: staging
  url: http://hostname/$APP_NAME/$CI_BUILD_REF_NAME

The resulting url in the Gitlab UI is e.g.: http://hostname//master. $APP_NAME seems to resolve to an empty String, whereas the runner variable $CI_BUILD_REF_NAME resolves correctly.

GitLab Community Edition 8.13.0, gitlab-runner 1.7.1. What am I missing?

like image 914
Fabian Avatar asked Nov 08 '25 18:11

Fabian


2 Answers

From GitLab doc, the YAML-defined variables are supported with GitLab Runner 0.5.0 or higher and GitLab CI 7.14 or higher, so first, check your GitLab component versions.

Try also enabling debug, to have more clues on why this variable is not resolved:

job1:
  variables:
    CI_DEBUG_TRACE: "true"
like image 70
VonC Avatar answered Nov 10 '25 22:11

VonC


This is most likely a bug in GitLab Runner where the env variables are defined after the environment but before the script. Have you considered opening an issue? https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues

like image 28
Connor Shea Avatar answered Nov 10 '25 23:11

Connor Shea



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!