Skip to content
Snippets Groups Projects
Commit 24fa8674 authored by Benjamin EINAUDI's avatar Benjamin EINAUDI Committed by Pierre Smeyers
Browse files

feat: keyword to prevent variables substitution

parent d4410d28
No related branches found
No related tags found
No related merge requests found
...@@ -300,6 +300,23 @@ In order to be able to implement some **genericity** in your scripts and templat ...@@ -300,6 +300,23 @@ In order to be able to implement some **genericity** in your scripts and templat
* any [GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/#predefined-environment-variables) * any [GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/#predefined-environment-variables)
(ex: `${CI_ENVIRONMENT_URL}` to retrieve the actual environment exposed route) (ex: `${CI_ENVIRONMENT_URL}` to retrieve the actual environment exposed route)
You can prevent any line from being processed by appending `# nosubst` at the end of the line. For instance in the following example, `${REMOTE_SERVICE_NAME}` won't be replaced by its environment value during GitLab job execution:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}
data:
application.yml: |
remote:
some-service:
name: '${REMOTE_SERVICE_NAME}' # nosubst
```
> :warning: > :warning:
> >
> In order to be properly replaced, variables in your YAML descriptors shall be written with curly braces (ex: `${MYVAR}` and not `$MYVAR`). > In order to be properly replaced, variables in your YAML descriptors shall be written with curly braces (ex: `${MYVAR}` and not `$MYVAR`).
......
...@@ -236,7 +236,7 @@ stages: ...@@ -236,7 +236,7 @@ stages:
} }
function awkenvsubst() { function awkenvsubst() {
awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);val=ENVIRON[var];gsub(/["\\]/,"\\\\&", val);gsub("\n", "\\n", val);gsub("\r", "\\r", val);gsub("[$]{"var"}",val)}}1' awk '!/# *nosubst/{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);val=ENVIRON[var];gsub(/["\\]/,"\\\\&", val);gsub("\n", "\\n", val);gsub("\r", "\\r", val);gsub("[$]{"var"}",val)}}1'
} }
function exec_hook() { function exec_hook() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment