diff options
| author | Sean Packham <sean@seanpackham.com> | 2017-06-06 14:30:08 +0000 |
|---|---|---|
| committer | Sean Packham <sean@seanpackham.com> | 2017-06-06 14:30:08 +0000 |
| commit | de12e4e2049aea365bdd668a9b96240321e6d755 (patch) | |
| tree | 1d20f61d4130d609f7c099f94fd09c9d9e3598fb /doc/ci/variables | |
| parent | 606e9cefd881313043f6a8f4bf39fb0d798e22f5 (diff) | |
| parent | 1d0219a52660f4b242a085c1a34311714bb384cf (diff) | |
| download | gitlab-ce-de12e4e2049aea365bdd668a9b96240321e6d755.tar.gz | |
Merge branch 'docs/powershell-ci-vars' into 'master'
Add PowerShell to CI variable docs
See merge request !11935
Diffstat (limited to 'doc/ci/variables')
| -rw-r--r-- | doc/ci/variables/README.md | 34 |
1 files changed, 30 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/ |
