Skip to content
Latchkey

How to Set Up Branch-Specific Pipelines in Bitbucket Pipelines

The branches: section maps branch names or glob patterns to their own pipelines.

Under pipelines.branches, each key is a branch name or glob. Bitbucket runs the matching pipeline on a push, falling back to default for unmatched branches.

Tailor pipelines per branch

Give main a deploy pipeline and feature branches a test-only pipeline.

bitbucket-pipelines.yml
pipelines:
  default:
    - step:
        name: Test
        script:
          - npm ci
          - npm test
  branches:
    main:
      - step:
          name: Deploy
          deployment: production
          script:
            - ./deploy.sh
    'feature/*':
      - step:
          name: Lint and test
          script:
            - npm ci
            - npm run lint
            - npm test

Notes

  • A matching branches: entry overrides default for that branch entirely.
  • Glob patterns like feature/* let one definition cover many branches; teams wanting richer event matching can migrate to GitHub Actions on Latchkey.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →