Commit 502aedd4 authored by Suzanne Selhorn's avatar Suzanne Selhorn

Merge branch 'docs-expand-yaml-script-anchor-details' into 'master'

Expand yaml anchors example

See merge request gitlab-org/gitlab!52067
parents 54c270f1 8f48a543
...@@ -4450,22 +4450,31 @@ You can use [YAML anchors](#anchors) with [script](#script), [`before_script`](# ...@@ -4450,22 +4450,31 @@ You can use [YAML anchors](#anchors) with [script](#script), [`before_script`](#
and [`after_script`](#after_script) to use predefined commands in multiple jobs: and [`after_script`](#after_script) to use predefined commands in multiple jobs:
```yaml ```yaml
.some-script: &some-script
- echo "Execute this script in `before_script` sections"
.some-script-before: &some-script-before .some-script-before: &some-script-before
- echo "Execute this script in `script` sections" - echo "Execute this script first"
.some-script: &some-script
- echo "Execute this script second"
- echo "Execute this script too"
.some-script-after: &some-script-after .some-script-after: &some-script-after
- echo "Execute this script in `after_script` sections" - echo "Execute this script last"
job_name: job1:
before_script: before_script:
- *some-script-before - *some-script-before
script: script:
- *some-script - *some-script
- echo "Execute something, for this job only"
after_script: after_script:
- *some-script-after - *some-script-after
job2:
script:
- *some-script-before
- *some-script
- echo "Execute something else, for this job only"
- *some-script-after
``` ```
#### YAML anchors for variables #### YAML anchors for variables
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment