Commit 4296b032 authored by Marcel Amirault's avatar Marcel Amirault

Merge branch 'quotes' into 'master'

Quote bash substitutions

See merge request gitlab-org/gitlab!60429
parents e0adec51 61cff6bf
...@@ -43,7 +43,7 @@ predefined variable: ...@@ -43,7 +43,7 @@ predefined variable:
test_variable: test_variable:
stage: test stage: test
script: script:
- echo $CI_JOB_STAGE - echo "$CI_JOB_STAGE"
``` ```
The script outputs the `stage` for the `test_variable`, which is `test`: The script outputs the `stage` for the `test_variable`, which is `test`:
...@@ -88,7 +88,7 @@ job1: ...@@ -88,7 +88,7 @@ job1:
variables: variables:
TEST_VAR_JOB: "Only job1 can use this variable's value" TEST_VAR_JOB: "Only job1 can use this variable's value"
script: script:
- echo $TEST_VAR and $TEST_VAR_JOB - echo "$TEST_VAR" and "$TEST_VAR_JOB"
``` ```
Variables saved in the `.gitlab-ci.yml` file should store only non-sensitive project Variables saved in the `.gitlab-ci.yml` file should store only non-sensitive project
...@@ -114,9 +114,9 @@ name inside another variable: ...@@ -114,9 +114,9 @@ name inside another variable:
```yaml ```yaml
variables: variables:
FLAGS: '-al' FLAGS: '-al'
LS_CMD: 'ls $FLAGS $$TMP_DIR' LS_CMD: 'ls "$FLAGS" $$TMP_DIR'
script: script:
- 'eval $LS_CMD' # Executes 'ls -al $TMP_DIR' - 'eval "$LS_CMD"' # Executes 'ls -al $TMP_DIR'
``` ```
Use the [`value` and `description`](../yaml/README.md#prefill-variables-in-manual-pipelines) Use the [`value` and `description`](../yaml/README.md#prefill-variables-in-manual-pipelines)
...@@ -151,10 +151,10 @@ After you create a variable, you can use it in the `.gitlab-ci.yml` file: ...@@ -151,10 +151,10 @@ After you create a variable, you can use it in the `.gitlab-ci.yml` file:
test_variable: test_variable:
stage: test stage: test
script: script:
- echo $CI_JOB_STAGE # calls a predefined variable - echo "$CI_JOB_STAGE" # calls a predefined variable
- echo $TEST # calls a custom variable of type `env_var` - echo "$TEST" # calls a custom variable of type `env_var`
- echo $GREETING # calls a custom variable of type `file` that contains the path to the temp file - echo "$GREETING" # calls a custom variable of type `file` that contains the path to the temp file
- cat $GREETING # the temp file itself contains the variable value - cat "$GREETING" # the temp file itself contains the variable value
``` ```
The output is: The output is:
...@@ -366,7 +366,7 @@ CI/CD variable with (`$`): ...@@ -366,7 +366,7 @@ CI/CD variable with (`$`):
```yaml ```yaml
job_name: job_name:
script: script:
- echo $CI_JOB_ID - echo "$CI_JOB_ID"
``` ```
### Use variables with PowerShell ### Use variables with PowerShell
...@@ -506,7 +506,7 @@ build: ...@@ -506,7 +506,7 @@ build:
deploy: deploy:
stage: deploy stage: deploy
script: script:
- echo $BUILD_VERSION # Output is: 'hello' - echo "$BUILD_VERSION" # Output is: 'hello'
dependencies: dependencies:
- build - build
``` ```
...@@ -525,7 +525,7 @@ build: ...@@ -525,7 +525,7 @@ build:
deploy: deploy:
stage: deploy stage: deploy
script: script:
- echo $BUILD_VERSION # Output is: 'hello' - echo "$BUILD_VERSION" # Output is: 'hello'
needs: needs:
- job: build - job: build
artifacts: true artifacts: true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment