How to Configure Branch-Specific Pipelines in Bitbucket Pipelines
The branches section maps branch names or glob patterns to their own list of steps, overriding the default pipeline.
Under pipelines.branches, add keys that are exact names or glob patterns (such as feature/*). The most specific match wins; unmatched branches fall back to default.
Steps
- Add a
branches:section underpipelines. - Use exact names (
main) or globs (release/*) as keys. - Keep a
default:for branches that match nothing.
bitbucket-pipelines.yml
bitbucket-pipelines.yml
pipelines:
default:
- step:
script:
- npm test
branches:
main:
- step:
deployment: production
script:
- ./deploy.sh
'feature/*':
- step:
script:
- npm run test:fastGotchas
- Glob keys with special characters must be quoted in YAML.
- If a branch matches a
brancheskey, thedefaultpipeline does not also run for it.
Related guides
How to Run Pull Request Pipelines in Bitbucket PipelinesRun a pipeline only when a pull request is open with the pull-requests section, which merges the source and d…
How to Run Tag Pipelines in Bitbucket PipelinesTrigger a Bitbucket Pipelines release build only when a Git tag is pushed using the tags section with a glob…