I am testing with using !reference
in rules
.
https://docs.gitlab.com/ee/ci/yaml/README.html#reference-tags
source:
rules:
- if: '$GITLAB_CI == "true"'
script:
- echo hi
test:
rules:
- !reference [source, rules]
script:
- echo hi
With the above config I get the following error.
This GitLab CI configuration is invalid: jobs:test rules should be an array of hashes.
I’m not sure if this is a bug in the docs (it doesn’t say where !reference
can/can’t be used) or a bug in the !reference
for rules itself.
Rules are one of the places I find a lot of duplication, but always with some variation.
This means the !reference option is of great value.
1 Like
I have mentioned this topic in this issue: CI rules parameter hard to generalize across jobs (#35093) · Issues · GitLab.org / GitLab · GitLab
Feel free to leave a comment in the issues if you think its related and would help you.
This forum doesn’t seem active. It’s worth ceasing coming here…
Since April noone has answer a thing.
Man, you should have used:
...
rules: !reference [source, rules]`
syntax instead.
Don’t ask me why, there is no logic, as exactly this syntax works perfectly for another arrays - scripts
.
E.g:
...
scripts:
- !reference [scripts1, scripts]
- !reference [scripts2, scripts]
I’m gonna ask on SO only from now on.
pitprok
4
Thank you! This was driving me crazy. This is 100% the solution.