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 testNotes
- 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
How to Define a Custom Pipeline Trigger in Bitbucket PipelinesCreate a manually triggered Bitbucket Pipelines workflow under the custom: section so an operator can run a n…
How to Deploy to AWS in Bitbucket PipelinesDeploy to AWS from Bitbucket Pipelines by configuring AWS credentials as secured repository variables and run…