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
c6ca74b8
Commit
c6ca74b8
authored
Jun 09, 2020
by
Ben Bodenmiller
Committed by
Marcel Amirault
Jun 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coloring script output details to GitLab CI YAML docs
parent
4c1dff36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+38
-0
No files found.
doc/ci/yaml/README.md
View file @
c6ca74b8
...
...
@@ -661,6 +661,44 @@ job:
[
YAML anchors for `before_script` and `after_script`
](
#yaml-anchors-for-before_script-and-after_script
)
are available.
#### Coloring script output
Script output can be colored using
[
ANSI escape codes
](
https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
)
,
or by running commands or programs that output ANSI escape codes.
For example, using
[
Bash with color codes
](
https://misc.flogisoft.com/bash/tip_colors_and_formatting
)
:
```
yaml
job
:
script
:
-
echo -e "\e[31mThis text is red,\e[0m but this text isn't\e[31m however this text is red again."
```
You can define the color codes in Shell variables, or even
[
custom environment variables
](
../variables/README.md#custom-environment-variables
)
,
which makes the commands easier to read and reusable.
For example, using the same example as above and variables defined in a
`before_script`
:
```
yaml
job
:
before_script
:
-
TXT_RED="\e[31m" && TXT_CLEAR="\e[0m"
script
:
-
echo -e "${TXT_RED}This text is red,${TXT_CLEAR} but this part isn't${TXT_RED} however this part is again."
-
echo "This text is not colored"
```
Or with
[
PowerShell color codes
](
https://superuser.com/a/1259916
)
:
```
yaml
job
:
before_script
:
-
$esc="$([char]27)"; $TXT_RED="$esc[31m"; $TXT_CLEAR="$esc[0m"
script
:
-
Write-Host $TXT_RED"This text is red,"$TXT_CLEAR" but this text isn't"$TXT_RED" however this text is red again."
-
Write-Host "This text is not colored"
```
### `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