Secret variables with a dollar sign are not correctly set
Asked Answered
S

2

7

when trying to use a secret variable with a value containing dollar sign on gitlab-ci secret variables it's not got variable value correctly.

Samphire answered 16/1, 2022 at 10:14 Comment(1)
This is discussed in depth over here: gitlab.com/gitlab-org/gitlab-foss/-/issues/27436Profusion
S
8

the solution is to set the dollar sign twice, for example, if your variable value is 123$567 put it like this: 123$$567

Samphire answered 16/1, 2022 at 10:14 Comment(0)
C
1

While escaping $ (with $$) is one way, but GitLab 15.7 (December 2022) adds another option:

Support the $ character in CI/CD variables

Support the $ character in CI/CD variables

Previously, using the $ character in a CI/CD variable always indicated the start of a reference another variable, which GitLab then tried to expand.
As a result, you could not have a value with a $ as part of the string unless it was escaped, which can be confusing.

In this release, we are introducing a new setting for project, group, and instance CI/CD variables.

You can now toggle whether or not GitLab interprets the CI/CD variable as a raw string, or treats a $ as the start of another variable that should be expanded.

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfhWmf0cC2nZ7-sWV9QWRft/images/15_7/raw.png -- Support the $ character in CI/CD variables

See Documentation and Issue.

Cartier answered 24/12, 2022 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.