<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>

CC BY-SA 4.0
2023-04-16T10:55:06.857Z
2023-04-16T11:36:46.077Z
2023-04-16T11:36:46.077Z
Václav Zindulka
<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>

CC BY-SA 4.0
2023-02-16T02:48:59.307Z
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.
LLlAMnYP
<gitlab><variables>
How to change value of pre-defined variable in GitLab to all lowercase
wwillfred
# 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:
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:]')


---

