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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
311a0e23
Commit
311a0e23
authored
Jun 18, 2020
by
Ben Bodenmiller
Committed by
Marcel Amirault
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add multiline GitLab CI scripts command details
parent
5e781062
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
+95
-0
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+95
-0
No files found.
doc/ci/yaml/README.md
View file @
311a0e23
...
...
@@ -699,6 +699,101 @@ job:
-
Write-Host "This text is not colored"
```
#### Multiline commands
You can split long commands into multi-line commands to improve readability
using
[
`|` (literal) and `>` (folded) YAML multiline block scalar indicators
](
https://yaml-multiline.info/
)
.
CAUTION:
**Warning:**
If multiple commands are combined into one command string, only the last command's
failure or success will be reported,
[
incorrectly ignoring failures from earlier commands due to a bug
](
https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25394
)
.
If the success of the job depends on the success or failure of these commands,
you can run the commands as separate
`script:`
items, or add
`exit 1`
commands
as appropriate to the command string where needed.
You can use the
`|`
(literal) YAML multiline block scalar indicator to write
commands over multiple lines in the
`script`
section of a job description.
Each line is treated as a separate command.
Only the first command is repeated in the job log, but additional
commands are still executed:
```
yaml
job
:
script
:
-
|
echo "First command line."
echo "Second command line."
echo "Third command line."
```
The example above renders in the job log as:
```
shell
$
echo
First
command
line
# collapsed multi-line command
First
command
line
Second
command
line.
Third
command
line.
```
The
`>`
(folded) YAML multiline block scalar indicator treats empty lines between
sections as the start of a new command:
```
yaml
job
:
script
:
-
>
echo "First command line
is split over two lines."
echo "Second command line."
```
This behaves similarly to writing multiline commands without the
`>`
or
`|`
block
scalar indicators:
```
yaml
job
:
script
:
-
echo "First command line
is split over two lines."
echo "Second command line."
```
Both examples above render in the job log as:
```
shell
$
echo
First
command
line is
split
over two lines.
# collapsed multi-line command
First
command
line is
split
over two lines.
Second
command
line.
```
When the
`>`
or
`|`
block scalar indicators are omitted, GitLab will form the command
by concatenating non-empty lines, so make sure the lines can run when concatenated.
Shell
[
here documents
](
https://en.wikipedia.org/wiki/Here_document
)
work with the
`|`
and
`>`
operators as well. The example below transliterates the lower case letters
to upper case:
```
yaml
job
:
script
:
-
|
tr a-z A-Z << END_TEXT
one two three
four five six
END_TEXT
```
Results in:
```
shell
$
tr
a-z A-Z
<<
END_TEXT
# collapsed multi-line command
ONE TWO THREE
FOUR FIVE SIX
```
### `stage`
`stage`
is defined per-job and relies on
[
`stages`
](
#stages
)
which is defined
...
...
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