Answers: <p>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.</p>
  <pre><code>before_script:
  - export CI_PROJECT_NAMESPACE=$(echo &quot;$CI_PROJECT_NAMESPACE&quot; | tr '[:upper:]' '[:lower:]')
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-04-16T10:55:06.857Z
Answers: 2023-04-16T11:36:46.077Z
Answers: 2023-04-16T11:36:46.077Z
Answers: Václav Zindulka
Body: <p>My environment requires the use of the predefined variable <code>CI_PROJECT_NAMESPACE</code> in <code>.gitlab-ci.yml</code>; 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:</p>
  <pre class="lang-yml prettyprint-override"><code>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
  </code></pre>
  <p>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!</p>
  
Comments: CC BY-SA 4.0
Comments: 2023-02-16T02:48:59.307Z
Comments: You're on the right track with your before_script, but there are some quoting issues. It helps to test out these commands in a local shell first.
Comments: LLlAMnYP
Tags: <gitlab><variables>
Title: How to change value of pre-defined variable in GitLab to all lowercase
UserDisplayName: wwillfred
ThreadText: # How to change value of pre-defined variable in GitLab to all lowercase
  
  (Asked by: username_0 on 2023-02-15)
  
  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:
  
  ```yml
  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!
  
  **Tags:** gitlab, variables
  
  > **Comments:**
  > **username_1**: You're on the right track with your before_script, but there are some quoting issues. It helps to test out these commands in a local shell first.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-04-16. Score: 2 | Accepted answer
  
  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:]')
  
  ```
  
  
  ---
  
  