CI/CD Variables - They won't make it to docker

Hello All,
we have problém with GitLab CI/CD Variables - Type File or Variable.

If I set the value directly in .gitlab-ci.yml, everything appear in docker, see attachments.




4

If I take the value from GitLab CI/CD, the value does not appear in docker, see attachments.



GitLab

Can you please advise where the fault is? Thank you

Same issue but with kubernetes executor.

I have opened a support ticket.

@sedivyz did you try to run your job with CI_DEBUG_TRACE=true ?
You will be able to see if project variable are injected or not.

On my side, variables are injected on every steps before job script. I mean that it’s available in pre-clone, post-clone and pre-build hook scripts. But not at job script.

1 Like

@cyril.marin Thank you for your messenge. :slight_smile:

Project variables are injected.

So that the problem is on the side of docker, which does not take variables? Any ideas what it could be please?

Thank you.

Could the problem be in the following warning?

time=“2023-04-11T17:17:21+02:00” level=warning msg=“The "_qr" variable is not set. Defaulting to a blank string.”

After some more investigations on my problem, i found that it was a missconfiguration in Yarn (it’s a js application).

I bet in your situation the issue is arround docker-compose, not related to gitlab-ci .
If i where you, I would check variable interpolation in docker-compose and precedence.

Solution was make export Variables and delete created images dockers from past.

Thank you for clue.

variables:
  SECRET_KEY_PROD: $DJANGO_SECRET_KEY_PROD

  CI_DEBUG_TRACE: "true"


build:
  rules: 
    - if: '$CI_COMMIT_REF_NAME == "main"'
  stage: build

  environment:
    name: main
    url: https://XXXXXXX
    

  script:
  - export SECRET_KEY_PROD="${DJANGO_SECRET_KEY_PROD}"
  - docker-compose --file docker-compose.prod.yaml up -d --build

stages:
- build