how to configure bitbucket-pipelines.yml file for multiple repository branches

Mohan Subramanya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 19, 2025

We have a repository where we created dev, qa and uat as branches under main. I want to setup CI/CD pipeline for deployment process and our's is hybrid environment. Database server is on-prem and repo on bitbucket cloud. Help me configure bitbucket-pipelines.yml for different these branches.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2025

Hi Mohan and welcome to the community!

It is possible to configure a different pipeline for each branch. The start conditions of pipelines are documented here, what you're looking for is in the branches section:

You could use a bitbucket-pipelines.yml like the following to configure a different build for each branch:

image: node:lts

pipelines:
branches:
dev:
- step:
script:
- echo "This script runs only on commit to the dev branch."
qa:
- step:
image: openjdk:8 # This step uses its own image
script:
- echo "This script runs only on commit to the qa branch."
uat:
- step:
image: openjdk:8 # This step uses its own image
script:
- echo "This script runs only on commit to the uat branch."


Each of these pipelines will get triggered automatically when there are new commits on the respective branch. This bitbucket-pipelines.yml will need to exist on all the branches you want to run pipelines for.

If you use Pipelines on Atlassian's infrastructure, the image parameter defines your build environment. Each step of a Pipelines build runs in a Docker container based on the image you specify in your bitbucket-pipelines.yml file. You can read more here:

The same applies if you use a self-hosted Linux Docker runner on your own server. Exceptions to that are builds running with a self-hosted Linux Shell, MacOS, or Windows runner, which run directly on the host machine and not in a Docker container:

If you run your builds on Atlassian's infrastructure and you need to connect to your on-prem server, and that server is behind a firewall restricting access, you can find the IPs used by Pipelines builds environments here:

If you have any questions, please feel free to reach out!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events