Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
de12e4e2
Commit
de12e4e2
authored
Jun 06, 2017
by
Sean Packham
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'docs/powershell-ci-vars' into 'master'
Add PowerShell to CI variable docs See merge request !11935
parents
606e9cef
1d0219a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
4 deletions
+49
-4
doc/ci/variables/README.md
doc/ci/variables/README.md
+30
-4
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+19
-0
No files found.
doc/ci/variables/README.md
View file @
de12e4e2
...
...
@@ -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/
doc/ci/yaml/README.md
View file @
de12e4e2
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment