I wanna write DRY YAML code for a CircleCI config file and researched a bit about YAML.

The output that I want

steps:
  - run:
      name: Foo
      command: echo foo
  - run:
      name: Bar
      command: echo bar
  - run:
      name: Buz
      command: echo buz

The solution

_vars: # namespace but almost meaningless
  - &item1
    run:
      name: Foo
      command: echo foo
  - &item2
    run:
      name: Bar
      command: echo bar

steps:
  - *item1
  - *item2
  - run:
      name: Buz
      command: echo buz

But I wanted to do like the following:

mylist: &mylist
  - run:
      name: Foo
      command: echo foo
  - run:
      name: Bar
      command: echo bar

steps:
  <<: &mylist
  - run:
      name: Buz
      command: echo buz

But this doesn’t work :sob: