Branch workflows

You can handle branches in Bitbucket Pipelines by adding branch-specific configuration in your bitbucket-pipelines.yml file.

 


 

Let's say that your bitbucket-pipelines.yml file looks like this:

bitbucket-pipelines.yml
image: node:5.11.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: java:openjdk-9 # 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 commit to a branch, Pipelines executes a set of scripts assigned to the branch in the bitbucket-pipelines.yml file:

where:

    • master contains build instructions that are executed on a commit to master
    • feature/* contains build instructions that are executed on a commit to any feature branch (that's our BB-123-fix-links branch)
    • default contains build instructions that are executed on a commit to any branch that is not master or feature (that's our experimental branch)

Note that the branch builds are triggered only if the bitbucket-pipelines.yml file requirements for a branch are met.

 


 

 

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport