Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Branch specific build triggers

Hi there,

Is it possible with BitBucket to trigger different Bamboo build plans based on which branch was updated?


6 answers

4 votes
SGD Atlassian Team Feb 13, 2013

Hi Matin-

Bamboo does actually support setting triggers for branch builds that are different from master's triggers.

First, make sure you have plan branches enabled. Go to ${PLAN} > Configure Plan > Branches and check the box marked "Automatically manage branches". Bamboo will search through your Bitbucket repo and clone your CI scheme for each of the branches it finds.

With that in place, you can adjust the trigger for your branch if you want to. Polling the branch for changes every 30 seconds is a pretty common option. Go to ${PLAN} > ${BRANCH} > Configure Branch. There's an option to change the trigger type for your branch. You can also fine-tune the notifications and variables for each branch while you're there.

If I have 'automatically manage branches' set I would not want to manually manage each branch by configuring it to have a different trigger. In a scenario where I want my 'feature' branch plans to have different stages to the 'develop' branch they come off of, I will use separate plans due to not wanting some stages to only be available from certain branches. This is following a video posted on an atlassian blog for the gitflow scenario. (!topic/maven-jgitflow-users/qqlemk-8tKY)

In this video, the trigger behaviour was highlighted as a bug, and then a ""feature"". I have no desire to repeat develop branch builds 3 times, and see it as a bug. Why can't I have the main plan not trigger automatically but the branch plans trigger automatically, without having to manually update every automatically created branch plan (defeating the purpose). The only workaround I can think of is to have the main trigger track a dummy branch that never changes and poll this, such that branch plans tracking feature branches will poll and find changes. It is not an appealing workaround - am I missing something?

Any help appreciated. At the moment, it doesn't seem like plans that automatically manage branches are meant to handle branches any differently from the mainline repository branch.

I've got the exact same problem. A change to a branch triggers the build on master and not on the branch...
That's weird that these two tools are not able to communicate correctly.

I would appreciate if someone find a solution. It's sad that we have to use polling. The process is less reactive with that...

I un-marked this as an answer. Unfortunately this approach does not work if you have automatic branch management.

Like Bob Tai likes this
2 votes

You can implement extremely flexible (conditional, branch-dependent, etc.) Bamboo builds with the Better DevOps Automation app by creating a new automation rule:

  1. Use the Commit Created Trigger to start the rule.
  2. Add a condition that compares the branch name to your desired branch name and continues the rule only if those are equal (or match a regex, etc.). You can access the branch name via the smart value {{devops.commit.branch}} (reference).
  3. Use the Run Groovy Script action with one of the ready-made Groovy scripts which start a Bamboo build.

This approach is highly customizable. Here is an advanced example where the build can be selected from the commit message (it's different from your use case, but demonstrates the flexibility very well):


We had trouble getting our branch-specific Bamboo builds triggered by Bitbucket Cloud for our Solinor's Payment Highway, but managed to fix this using the following solution:

You should still configure rather low, e.g. 60 seconds Branch detection interval (System -> General configuration) as unlike in Stash, new branches are not pushed, but rather pulled. However after pulled once, the new pushes will trigger builds via the remote trigger.

Hi Martin,

There are no separate triggeres for branch plans; there is only the default trigger, and we track this issue. You can run this command and trigger a branch plan:

curl -X POST --user admin:admin "http://localhost:8085/rest/api/latest/queue/PROJ1-PLAN10?executeAllStages=true"

where 'admin:admin' is the username:password of your Bamboo user, and 'PROJ1-PLAN10' is the plan branch key. I hope this answers your question.


SGD Atlassian Team Feb 13, 2013

There are no separate triggeres for branch plans

Good news! Bamboo does support this. See my answer below :o)

Sarah - thanks for your notes on this. So I followed your steps, enabbled "Automatically manage branches" and under branches I see the branch that I want Bamboo to run trigger the shell command scripts. But these shell scripts are associated to "Default Job" under "Default Stage" and Bamboo still triggers the plan even though I commited and pushed changes to a different branch than the one I m interest in. I mean I don't see plan specific tasks, so the master triggers are the ones that get executed. What am I missing?

P.S. Bamboo 5.3 build 4101


0 votes
aMarcus Atlassian Team Feb 10, 2013

Hi there Matin,

Bitbucket simply triggers when any code is pushed to Bitbucket. You can configure what you are looking for in Bamboo. Check out the documentation on plan branching.

Thanks for that Marcus.

I guess the issue im having is that a commit to a non-master branch only seems to trigger in Bamboo the main build plan, rather than the associated plan branch.

i.e. if i push to a "test" branch in BitBucket, the main build plan configured in the Services option is run, and not the branch plan created specifically for the "test" branch.

Any advice you may have would be appreciated.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,755 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you