Commit 4d28ebc6 authored by Evan Read's avatar Evan Read

Merge branch 'docs-before-script-clarification' into 'master'

Clarify before and after script details

Closes #34288

See merge request gitlab-org/gitlab!19281
parents b36e26cb 5e30c45a
...@@ -259,34 +259,26 @@ For more information, see see [Available settings for `services`](../docker/usin ...@@ -259,34 +259,26 @@ For more information, see see [Available settings for `services`](../docker/usin
> Introduced in GitLab 8.7 and requires GitLab Runner v1.2. > Introduced in GitLab 8.7 and requires GitLab Runner v1.2.
`before_script` is used to define the command that should be run before all `before_script` is used to define a command that should be run before each
jobs, including deploy jobs, but after the restoration of [artifacts](#artifacts). job, including deploy jobs, but after the restoration of any [artifacts](#artifacts).
This must be an an array. This must be an an array.
`after_script` is used to define the command that will be run after all Scripts specified in `before_script` are concatenated with any scripts specified
jobs, including failed ones. This must be an an array. in the main [`script`](#script), and executed together in a single shell.
Scripts specified in `before_script` are: `after_script` is used to define the command that will be run after each
job, including failed ones. This must be an an array.
- Concatenated with scripts specified in the main `script`. Job-level Scripts specified in `after_script` are executed in a new shell, separate from any
`before_script` definition override global-level `before_script` definition `before_script` or `script` scripts. As a result, they:
when concatenated with `script` definition.
- Executed together with main `script` script as one script in a single shell
context.
Scripts specified in `after_script`:
- Have a current working directory set back to the default. - Have a current working directory set back to the default.
- Are executed in a shell context separated from `before_script` and `script` - Have no access to changes done by scripts defined in `before_script` or `script`, including:
scripts. - Command aliases and variables exported in `script` scripts.
- Because of separated context, cannot see changes done by scripts defined - Changes outside of the working tree (depending on the Runner executor), like
in `before_script` or `script` scripts, either: software installed by a `before_script` or `script` script.
- In shell. For example, command aliases and variables exported in `script`
scripts. It's possible to overwrite a globally defined `before_script` or `after_script`
- Outside of the working tree (depending on the Runner executor). For example,
software installed by a `before_script` or `script` scripts.
It's possible to overwrite the globally defined `before_script` and `after_script`
if you set it per-job: if you set it per-job:
```yaml ```yaml
......
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