summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Packham <sean@seanpackham.com>2017-06-06 14:30:08 +0000
committerSean Packham <sean@seanpackham.com>2017-06-06 14:30:08 +0000
commitde12e4e2049aea365bdd668a9b96240321e6d755 (patch)
tree1d20f61d4130d609f7c099f94fd09c9d9e3598fb
parent606e9cefd881313043f6a8f4bf39fb0d798e22f5 (diff)
parent1d0219a52660f4b242a085c1a34311714bb384cf (diff)
downloadgitlab-ce-de12e4e2049aea365bdd668a9b96240321e6d755.tar.gz
Merge branch 'docs/powershell-ci-vars' into 'master'
Add PowerShell to CI variable docs See merge request !11935
-rw-r--r--doc/ci/variables/README.md34
-rw-r--r--doc/ci/yaml/README.md19
2 files changed, 49 insertions, 4 deletions
diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md
index 23c93c59604..76ba78ea7be 100644
--- a/doc/ci/variables/README.md
+++ b/doc/ci/variables/README.md
@@ -345,20 +345,45 @@ All variables are set as environment variables in the build environment, and
they are accessible with normal methods that are used to access such variables.
In most cases `bash` or `sh` is used to execute the job script.
-To access the variables (predefined and user-defined) in a `bash`/`sh` environment,
-prefix the variable name with the dollar sign (`$`):
+To access environment variables, use the syntax for your Runner's [shell][shellexecutors].
-```
+| Shell | Usage |
+|----------------------|-----------------|
+| bash/sh | `$variable` |
+| windows batch | `%variable%` |
+| PowerShell | `$env:variable` |
+
+To access environment variables in bash, prefix the variable name with (`$`):
+
+```yaml
job_name:
script:
- echo $CI_JOB_ID
```
+To access environment variables in **Windows Batch**, surround the variable
+with (`%`):
+
+```yaml
+job_name:
+ script:
+ - echo %CI_JOB_ID%
+```
+
+To access environment variables in a **Windows PowerShell** environment, prefix
+the variable name with (`$env:`):
+
+```yaml
+job_name:
+ script:
+ - echo $env:CI_JOB_ID
+```
+
You can also list all environment variables with the `export` command,
but be aware that this will also expose the values of all the secret variables
you set, in the job log:
-```
+```yaml
job_name:
script:
- export
@@ -405,3 +430,4 @@ export CI_REGISTRY_PASSWORD="longalfanumstring"
[triggers]: ../triggers/README.md#pass-job-variables-to-a-trigger
[protected branches]: ../../user/project/protected_branches.md
[protected tags]: ../../user/project/protected_tags.md
+[shellexecutors]: https://docs.gitlab.com/runner/executors/
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index dd4b589d37c..fc813694ff2 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -297,6 +297,15 @@ cache:
untracked: true
```
+If you use **Windows PowerShell** to run your shell scripts you need to replace
+`$` with `$env:`:
+
+```yaml
+cache:
+ key: "$env:CI_JOB_STAGE/$env:CI_COMMIT_REF_NAME"
+ untracked: true
+```
+
## Jobs
`.gitlab-ci.yml` allows you to specify an unlimited number of jobs. Each job
@@ -909,6 +918,16 @@ job:
untracked: true
```
+If you use **Windows PowerShell** to run your shell scripts you need to replace
+`$` with `$env:`:
+
+```yaml
+job:
+ artifacts:
+ name: "$env:CI_JOB_STAGE_$env:CI_COMMIT_REF_NAME"
+ untracked: true
+```
+
#### artifacts:when
> Introduced in GitLab 8.9 and GitLab Runner v1.3.0.