We have a ton of configuration that is the same across multiple repos, and make heavy use of YAML anchors/aliases. We recently built and implemented a CircleCI Orb to reduce duplication for jobs, which was great! However, we’d like to take it a step further. Is it possible to configure YAML anchors/aliases in an Orb and invoke them from a project’s configuration?
There are some threads that seem related:
However, these questions are about using anchors/aliases in other portions of the same Orb. They do seem to imply that the scope of an anchor/alias is limited to a single YAML file, which would be disappointing.
I want to use an Orb’s preconfigured YAML anchors/aliases in a project’s workflow outside of the Orb itself. Any insight would be greatly appreciated! Thanks in advance.
Anchors and aliases are a feature of YAML, not CircleCI config. They are definitely limited to a single file, as they aren’t ingested by CircleCI but rather automatically parsed by any common YAML parser.
To share config across multiple config files is how CircleCI came out with Orbs. Orbs are a specific feature of CircleCI that allows you to export and share snippets of CircleCI config.
Rather than using anchors and aliases to define a command for instance, it should be exported as a component of an orb.
So I’m specifically talking about branch/tag filters, contexts, and parameters.
If I’m understanding you correctly, you’re suggesting I just lift all that stuff up into the elements of the Orb itself and/or make them input parameters of Orb jobs rather than trying to export bits of the Orb for implementation in workflows.