@@ -114,6 +114,7 @@ a job-specific `image:` section:
...
@@ -114,6 +114,7 @@ a job-specific `image:` section:
that keyword defined.
that keyword defined.
- If a job already has one of the keywords configured, the configuration in the job
- If a job already has one of the keywords configured, the configuration in the job
takes precedence and is not replaced by the default.
takes precedence and is not replaced by the default.
- Control inheritance of default keywords in jobs with [`inherit:default`](#inheritdefault).
### `stages`
### `stages`
...
@@ -4194,84 +4195,80 @@ You must:
...
@@ -4194,84 +4195,80 @@ You must:
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/207484) in GitLab 12.9.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/207484) in GitLab 12.9.
Use `inherit:` to control inheritance of globally-defined defaults
Use `inherit:` to [control inheritance of globally-defined defaults and variables](../jobs/index.md#control-the-inheritance-of-default-keywords-and-global-variables).
and variables.
To enable or disable the inheritance of all `default:` or `variables:` keywords, use:
#### `inherit:default`
-`default: true` or `default: false`
Use `inherit:default` to control the inheritance of [default keywords](#default).
-`variables: true` or `variables: false`
To inherit only a subset of `default:` keywords or `variables:`, specify what
**Keyword type**: Job keyword. You can use it only as part of a job.
you wish to inherit. Anything not listed is **not** inherited. Use
one of the following formats:
```yaml
**Possible inputs**:
inherit:
default:[keyword1,keyword2]
-`true` (default) or `false` to enable or disable the inheritance of all default keywords.
variables:[VARIABLE1,VARIABLE2]
- A list of specific default keywords to inherit.
```
Or:
**Example of `inherit:default`:**
```yaml
```yaml
inherit:
default:
retry:2
image:ruby:3.0
interruptible:true
job1:
script:echo "This job does not inherit any default keywords."
inherit:
default:false
job2:
script:echo "This job inherits only the two listed default keywords. It does not inherit 'interruptible'."
inherit:
default:
default:
-keyword1
-retry
-keyword2
-image
variables:
-VARIABLE1
-VARIABLE2
```
```
In the following example:
**Additional details:**
-`rubocop`:
- You can also list default keywords to inherit on one line: `default: [keyword1, keyword2]`
- inherits: Nothing.
-`rspec`:
- inherits: the default `image` and the `WEBHOOK_URL` variable.
- does **not** inherit: the default `before_script` and the `DOMAIN` variable.
-`capybara`:
- inherits: the default `before_script` and `image`.
- does **not** inherit: the `DOMAIN` and `WEBHOOK_URL` variables.
-`karma`:
- inherits: the default `image` and `before_script`, and the `DOMAIN` variable.
- does **not** inherit: `WEBHOOK_URL` variable.
```yaml
#### `inherit:variables`
default:
image:'ruby:2.4'
before_script:
-echo Hello World
variables:
Use `inherit:variables` to control the inheritance of [global variables](#variables) keywords.
DOMAIN:example.com
WEBHOOK_URL:https://my-webhook.example.com
rubocop:
**Keyword type**: Job keyword. You can use it only as part of a job.
inherit:
default:false
variables:false
script:bundle exec rubocop
rspec:
**Possible inputs**:
inherit:
default:[image]
-`true` (default) or `false` to enable or disable the inheritance of all global variables.
variables:[WEBHOOK_URL]
- A list of specific variables to inherit.
script:bundle exec rspec
**Example of `inherit:variables`:**
capybara:
```yaml
variables:
VARIABLE1:"Thisisvariable1"
VARIABLE2:"Thisisvariable2"
VARIABLE3:"Thisisvariable3"
job1:
script:echo "This job does not inherit any global variables."
inherit:
inherit:
variables:false
variables:false
script:bundle exec capybara
karma:
job2:
script:echo "This job inherits only the two listed global variables. It does not inherit 'VARIABLE3'."
inherit:
inherit:
default:true
variables:
variables:[DOMAIN]
-VARIABLE1
script:karma
-VARIABLE2
```
```
**Additional details:**
- You can also list global variables to inherit on one line: `variables: [VARIABLE1, VARIABLE2]`