Variables in GitLab CI

So I’ve been using secret variables in our .gitlab-ci.yml file and have always defined them like so:

...
before_script:
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
...

or sometimes I’d use them as:

...
  environment:
    name: review/$CI_COMMIT_REF_NAME
...

This works perfectly for us but I came across a video last night where they made use of a variable in a different syntax:

${VAR_NAME}

Are there any differences between the different syntax I mentioned here? Are there situations where one of the syntax won’t work?

I think this answers your question: https://stackoverflow.com/q/8748831/5675425

1 Like

Thanks! That does give me an insight of what the differences are and when to use them.

1 Like

Just read the docs and it will be fine.

Thanks and welcome, @francis.rod01 !

Incidentally, I use your general docs advice all the time: :wink: