Allow nested lists in config.yml. `steps` List
complete
M
Md
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.CCI-I-424
J
Jon Hanno
Just to mention (for anyone else looking as I was) that this functionality is achievable using CircleCI v2.1: https://discuss.circleci.com/t/circleci-2-1-config-overview/26057
Don't forget to specify version: 2.1 in your config.yml
R
Rafal Enden
Works only with config 2.1 which isn't supported by circleci CLI.
Any solutions which works on 2.0?
N
Nathan Dintenfass
You can now do this with the
commands
stanza. https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commandsN
Nathan Dintenfass
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.
M
Md
Just saw https://discuss.circleci.com/t/allow-bundling-several-steps-e-g-by-supporting-nested-steps/15339 is the same issue. Can they be merged?