Commit 88799b2c authored by Matija Čupić's avatar Matija Čupić

Add documentation about script flattening

parent ca1ff463
...@@ -181,6 +181,25 @@ that the YAML parser knows to interpret the whole thing as a string rather than ...@@ -181,6 +181,25 @@ that the YAML parser knows to interpret the whole thing as a string rather than
a "key: value" pair. Be careful when using special characters: a "key: value" pair. Be careful when using special characters:
`:`, `{`, `}`, `[`, `]`, `,`, `&`, `*`, `#`, `?`, `|`, `-`, `<`, `>`, `=`, `!`, `%`, `@`, `` ` ``. `:`, `{`, `}`, `[`, `]`, `,`, `&`, `*`, `#`, `?`, `|`, `-`, `<`, `>`, `=`, `!`, `%`, `@`, `` ` ``.
#### YAML anchors for `script`
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/23005) in GitLab 12.5.
You can use [YAML anchors](#anchors) with scripts, which makes it possible to
include a predefined list of commands in multiple jobs.
Example:
```yaml
.something: &something
- echo 'something'
job_name:
script:
- *something
- echo 'this is the script'
```
### `image` ### `image`
Used to specify [a Docker image](../docker/using_docker_images.md#what-is-an-image) to use for the job. Used to specify [a Docker image](../docker/using_docker_images.md#what-is-an-image) to use for the job.
...@@ -284,6 +303,33 @@ job: ...@@ -284,6 +303,33 @@ job:
- execute this after my script - execute this after my script
``` ```
#### YAML anchors for `before_script` and `after_script`
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/23005) in GitLab 12.5.
You can use [YAML anchors](#anchors) with `before_script` and `after_script`,
which makes it possible to include a predefined list of commands in multiple
jobs.
Example:
```yaml
.something_before: &something_before
- echo 'something before'
.something_after: &something_after
- echo 'something after'
job_name:
before_script:
- *something_before
script:
- echo 'this is the script'
after_script:
- *something_after
```
### `stages` ### `stages`
`stages` is used to define stages that can be used by jobs and is defined `stages` is used to define stages that can be used by jobs and is defined
......
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