Branch workflows

You can change what your pipeline does depending on which branch you push to. All you need is some branch-specific configuration in your bitbucket-pipelines.yml file.

See also Configure bitbucket-pipelines.yml.

Here's an example:

image: node:10.15.0
    - step:
          - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
      - step:
            - echo "This script runs only on commit to the master branch."
      - step:
          image: openjdk:8 # This step uses its own image
            - 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.

tip/resting Created with Sketch.

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.

Last modified on Mar 12, 2019

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.