Can we use same branch name twice on a bitbucket pipeline file?

Aashish41
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!
November 30, 2022

I have a bitbucket pipeline file as below;

pipelines:

    branches:

      dev:

        - step:

            name: Test1

            script:

              - echo "Test"  

      dev:

        - step:

            name: Test2

            script:

              - echo "Test"
 When the pipeline is triggered only first step runs i.e. Test1 but Test2 doesn't. Is there any way that I can use same branch name twice?

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 2, 2022

Hi @Aashish41 and welcome to the community!

I don't believe that this is possible, however, a pipeline for a certain branch can have multiple steps.

If you want to execute both steps when a commit is pushed to dev branch, you can modify your bitbucket-pipelines.yml file as follows:

pipelines:
branches:
dev:
- step:
name: Test1
script:
- echo "Test"
- step:
name: Test2
script:
- echo "Test"

Is this what you are looking for?

Kind regards,
Theodora

Aashish41
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!
December 6, 2022

Hi @Theodora Boudale , Thank you for your response.

I have already opted using multiple steps for a single branch. I just wanted to know if it is possible to use same branch multiple times. Unfortunately, it is not possible.

Anyway your response was helpful for me. 

Have a great day !

Tridev Rai October 2, 2023

Hi @Theodora Boudale

Is there an alternative other than you create a unique branch name for your pipeline?

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 2, 2023

Hi Tridev,

You can create (multiple) custom pipelines:

Please keep in mind though that these can only be triggered manually or on a schedule, they don't run automatically on every push.

It is also possible to configure a default pipeline that will run automatically on every push if no branch-specific pipeline is defined:

The page I shared has all available options about Pipeline start conditions.

Kind regards,
Theodora

Tridev Rai October 2, 2023

Thank you @Theodora Boudale for your quick response.

I will go through this and let you know if any confusion arises.

Like Theodora Boudale likes this
Tridev Rai October 4, 2023

I had below requirements:

1. whenever the master/ hotfix branch is pushed it should be deployed in UAT environments.

2. After the QA team verifies the changes in UAT, the master branch should be deployed into production

 

since I couldn't use the same branch name in the pipelines. 

I used the custom pipeline to build and deploy in the production.

I also added a manual trigger in the deployment step and ensured it is only deployed by certain individuals.

 

Thanks @Theodora Boudale 

Suggest an answer

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

Atlassian Community Events