Ability to factor out common sequences of steps

circle.yml

#1

We have a bunch of jobs which start off very similar before going on to do their separate tasks, e.g. attaching the workspace, running setup_remote_docker etc. It would be great if those could be refactored into a common tagged block which could be included into each job in a DRY way. For setup_remote_docker this would also mean we would be sure that the Docker version used in each job did not skew.

I tried this with (a few variants on):

setup_docker: &setup_docker
  - setup_remote_docker:
      version: 17.06.1-ce
  - run:
      name: Docker version
      command: |
        docker version

jobs:
  a:
  [...]
  steps:
    <<: *setup_docker
    - step a.1
    - step a.2
  b:
  [...]
    <<: *setup_docker
    - step b.1
    - step b.2

But the result is a nested list:

  steps:
      - - setup_remote_docker:
            version: 17.06.1-ce
        - run:
             name: Docker version
             command: |
               docker version
      - step a.1
      - step a.2

Which doesn’t work.

It seems that what I want is not possible within the YAML syntax, but perhaps Circle could automatically flatten the nested lists when it comes across them?


#2

Seems like this indeed isn’t possible with YAML — I had to go and verify this myself, too :smile:


#3