You can change what your pipeline does depending on which branch you push to. All you need is some branch-specific configuration in your
See also Configure bitbucket-pipelines.yml.
Here's an example:
image: node:10.15.0 pipelines: default: - step: script: - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'." branches: master: - step: script: - echo "This script runs only on commit to the master branch." feature/*: - step: image: openjdk:8 # This step uses its own image script: - echo "This script runs only on commit to branches with names that match the feature/* pattern."
That example shows two branches based on the master branch:
- a branch called feature/BB-123-fix-links that is a feature branch
- a branch called experimental where your team can go crazy innovating and breaking stuff. This branch is not a feature branch.
The same bitbucket-pipelines.yml file lives in the root directory of each branch. On each push to a branch, Pipelines executes the scripts assigned to that branch in the bitbucket-pipelines.yml file:
- master step definition contains instructions that run on a commit to master
- feature/* definition contains instructions that run on a commit to any feature branch (that's our BB-123-fix-links branch)
- default definition contains instructions that run on a commit to any branch that is not master or feature (that's our experimental branch)
Note that the branch pipelines are triggered only if the bitbucket-pipelines.yml file requirements for a branch are met.
If you ever want to push a commit and skip triggering its pipeline, you can add
[skip ci] or
[ci skip] to the commit message.
For even more control, if you have the premium plan, you can add in a safeguard to only allow specific branches to deploy.