CircleCI Ideas

Allow nested lists in config.yml. `steps` List

Often I repetition inside the jobs-steps-List. By leveraging YAML alias and references one could have a macro like functionality in config.yml: 

stepslist: &stepslist
- checkout:
path: ~/repo
- run: doit -f dodo-new.py submodules
- restore_cache: …
- run: doit -f dodo-new.py BUILD
- save_cache: …

jobs:
build:…
steps:
- *stepslist
- run: doit -f dodo-new.py CICHECK CITEST


Using YAML  `<<:` merge as suggested in https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/ does not work with steps because steps is a list. Do the config shown above dos not work currently.
But if Circle CI would accept a list of lists (basically run `steps.flatten()`) it would enable using this functionality reducing config duplication without much added complexity. 

https://discuss.circleci.com/t/yaml-anchors-implementation-incomplete/16916 is the same problem.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • May 22 2018
  • Shipped
  • Attach files
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    May 22, 2018 12:36
  • Admin
    Nathan Dintenfass commented
    May 22, 2018 17:59

    We will be providing something akin to this in a coming set of configuration improvements -- we will let you define a command that is a set of parametrizable steps you can invoke in a job.

  • Admin
    Nathan Dintenfass commented
    December 07, 2018 22:09

    You can now do this with the `commands` stanza. https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    13 Jun 16:52

    Works only with config 2.1 which isn't supported by circleci CLI.

    Any solutions which works on 2.0?