Commit 24fa8674 authored by Benjamin EINAUDI's avatar Benjamin EINAUDI Committed by Pierre Smeyers
Browse files

feat: keyword to prevent variables substitution

parent d4410d28
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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)
      (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:
>
> In order to be properly replaced, variables in your YAML descriptors shall be written with curly braces (ex: `${MYVAR}` and not `$MYVAR`).
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ stages:
  }

  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() {