3

My environment requires the use of the predefined variable CI_PROJECT_NAMESPACE in .gitlab-ci.yml; however, this variable is in all caps, which makes my build job fail. I've tried several ways to convert the value of this variable to all lowercase with no success:

variables:
  CI_PROJECT_NAMESPACE: $CI_PROJECT_NAMESPACE | tr '[:upper:]' '[:lower:]' # doesn't work

build_image: stage: build image: name: #... entrypoint: #... before_script: - export CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE | tr '[:upper:]' '[:lower:]' # also doesn't work

I have successfully hard-coded this variable for my own use, but I need the script to work for other users as well without requiring them to hard-code it themselves. Thanks in advance for your thoughts!

wwillfred
  • 33
  • 1
  • 3

1 Answers1

2

You had it almost right. You just can't pipe variable itself to tr. You have to use echo in command substitution, which you can pipe to tr.

before_script:
- export CI_PROJECT_NAMESPACE=$(echo "$CI_PROJECT_NAMESPACE" | tr '[:upper:]' '[:lower:]')
Pierre.Vriens
  • 7,225
  • 14
  • 39
  • 84