Reusable configuration keys


#1

Can you provide more documentation around reusable configuration keys?

I see an example in the workflows documentation using &defaults and <<: *defaults syntax. I see that it’s possible to reuse the executor type configuration.

  1. If the reusable configuration declares one docker image, can it be reused in a job that declares additional docker images?
  2. Is it also possible to reuse the same set of steps across different jobs. Can they be inserted before the job specific steps?

#2

bump… any documentation on sharing configuration keys would be greatly appreciated!


#3

CircleCI configuration is just YAML. The syntax &defaults and <<: *defaults that you see are actually a feature of YAML called anchors and aliases. As a quick overview, you can checkout “YAML - Anchors, References, Extended” which shows how the features work and the equivalent JSON representation. That should give you a good idea of how you can reuse portions of your YAML document to DRY up your Circle configuration.


Using <<: *defaults syntax in config.yaml, AKA Yaml anchors
#4

Thanks for that. I didn’t realize that was YAML syntax. After doing some further digging, it doesn’t seem like we can share partial steps as YAML doesn’t allow for extending arrays.

For example, I have a bunch of jobs that share steps 1-5, but only step 6 is different.


#5

Getting workflows set up on CircleCI 2.0 has forced me to refresh my YAML knowledge.

If you’ve looking for an example of how to keep a non-trivial configuration DRY, then looking at CircleCI’s frontend isn’t a bad place to start:


#6

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.