Child job `rules` should always take precedence over parent job's `only`/`except` (and vice-versa)
Currently, if I have the following CI config:
job-a:
only:
refs:
- master
except:
refs:
- merge_requests
script: echo "foo"
job-b:
extends: job-a
rules:
- if: '$CI_MERGE_REQUEST_ID'
script: echo "bar"
I get a validation error:
jobs:job-b config key may not be used with `rules`: only, except
Note that we get the same problem if jobA
is defined in a template.
While the error is preventing clashing conditions, it would be great if rules
from a child job could always take precedence over only
/except
of its parent job so that we don't get the validation error (i.e. only
/except
would be dropped for the job-b
job since it declare rules
).
Notes:
-
That this proposal should work the same if
job-a
is defined in a template. -
The same thing should apply to rules (i.e.
rules
would be dropped for thejob-b
job since it declareonly
/except
):job-a: rules: - if: '$CI_MERGE_REQUEST_ID' script: echo "foo" jobb: extends: job-a only: refs: - master except: refs: - merge_requests script: echo "bar"
This proposal would greatly ease the update of our devopssecure templates from only
/except
to rules
(&2300 (closed)) and allow to not make this update a breaking change.