Bitbucket Pipelines - multiple branches with same steps

This is a full example on how you can reuse some steps:

image: yourimage:latest

definitions:
  services: ... # Service definitions go there
  steps:
    - step: &Test-step
        name: Run tests
        script:
          - npm install
          - npm run test
    - step: &Deploy-step
        name: Deploy to staging
        deployment: staging
        script:
          - npm install
          - npm run build
          - fab deploy
pipelines:
  default:
    - step: *Test-step
    - step: *Deploy-step
  branches:
      master:
        - step: *Test-step
        - step:
            <<: *Deploy-step
            deployment: production
            trigger: manual

Read more about YAML anchors: https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html


A comma-separated list inside braces appears to work:

pipelines:
  branches:
    '{rev,staging}':
      - step:
        script:
          - echo 'step'