Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab CI - Reuse rules with !reference tag

According to GitLab's CI documentation about !reference tag, it says:

Use the !reference custom YAML tag to select keyword configuration from other job sections and reuse it in the current section. Unlike YAML anchors, you can use !reference tags to reuse configuration from included configuration files as well.

Can we use the !reference tag to reuse rules or any other allowed keyword?

like image 875
psergiocf Avatar asked Nov 30 '25 04:11

psergiocf


1 Answers

See GitLab 14.3 (September 2021):

Support merging CI/CD rules arrays with !reference

The YAML !reference tag introduced earlier this year helps you reuse and combine configuration.
This is a very flexible way to combine frequently reused configuration with job-specific configuration in one or more jobs.

However, using it with the rules keyword was not supported yet.

In 14.3, we’ve added !reference support to the rules keyword, so you can now mix and match rules more easily, including with configuration from different files.
You can use the CI/CD pipeline editor to view the merged configuration.

https://about.gitlab.com/images/14_3/reuse_rules_in_different_jobs.png -- Support merging CI/CD rules arrays with !reference

See Documentation and Issue.

like image 51
VonC Avatar answered Dec 01 '25 17:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!