Skip to content

Commit 74aa047

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 83b3564 commit 74aa047

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

doc/editor_extensions/gitlab_cli/_index.md

+51-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ glab auth login --stdin < token.txt
3333
# View a list of issues
3434
glab issue list
3535

36-
# Create merge request for issue 123
36+
# Create merge request for issue 123
3737
glab mr create 123
3838

3939
# Check out the branch for merge request 243
@@ -113,6 +113,56 @@ To authenticate with your GitLab account, run `glab auth login`.
113113
`glab` also integrates with the [1Password shell plugin](https://developer.1password.com/docs/cli/shell-plugins/gitlab/)
114114
for secure authentication.
115115

116+
## Examples
117+
118+
### Run a CI/CD pipeline with variables from a file
119+
120+
The `glab ci run` command, when run with the `-f` (`--variables-from-string`) flag, uses values stored
121+
in an external file. For example, add this code to your `.gitlab-ci.yml` file
122+
to reference two variables:
123+
124+
```yaml
125+
stages:
126+
- build
127+
128+
# $EXAMPLE_VARIABLE_1 and $EXAMPLE_VARIABLE_2 are stored in another file
129+
build-job:
130+
stage: build
131+
script:
132+
- echo $EXAMPLE_VARIABLE_1
133+
- echo $EXAMPLE_VARIABLE_2
134+
- echo $CI_JOB_ID
135+
```
136+
137+
Then, create a file named `variables.json` to contain those variables:
138+
139+
```json
140+
[
141+
{
142+
"key": "EXAMPLE_VARIABLE_1",
143+
"value": "example value 1"
144+
},
145+
{
146+
"key": "EXAMPLE_VARIABLE_2",
147+
"value": "example value 2"
148+
}
149+
]
150+
```
151+
152+
To start a CI/CD pipeline that includes the contents of `variables.json`, run this command, editing
153+
the path to the file as needed:
154+
155+
```shell
156+
$ glab ci run --variables-file /tmp/variables.json`
157+
158+
$ echo $EXAMPLE_VARIABLE_1
159+
example value 1
160+
$ echo $EXAMPLE_VARIABLE_2
161+
example value 2
162+
$ echo $CI_JOB_ID
163+
9811701914
164+
```
165+
116166
## Report issues
117167

118168
Open an issue in the [`gitlab-org/cli` repository](https://gitlab.com/gitlab-org/cli/-/issues/new)

0 commit comments

Comments
 (0)