Why commits to branch trigger build on master (and not branch)?
Asked by Felipe Reis:

Hi!

I'm using Bamboo+Bitbucket (git repo). I have a project with the master branch and a development branch called PII-25.

I have configured Bamboo to automatically detect new branches. So, when I created PII-25, Bamboo has received the message and successfully created a new build plan for that branch.

However, whenever I commit a change on branch PII-25 Bamboo triggers a build on the master plan, not on the PII-25 plan as expected.

Thanks!


Answers:
author: Felipe Reis
body: After Piotr clarified the issue for me, I was able to find a thread describing the same problem I was facing with a viable workaround.

The solution is to change the build trigger to "Polling the repository for changes".

Here is the thread that helped me: [https://answers.atlassian.com/questions/135958/branch-specific-build-triggers](/questions/135958/branch-specific-build-triggers)

Thanks Piotr!

comments: author: PiotrA
body: :) you were faster than me


author: baratrion
body: I'm having the same problem. So, the only option I have is to enable polling instead of remote triggering?


author: PiotrA
body: > Is it possible to configure Bamboo+Bitbucket in a way that commits trigger builds on different plans, according to the branch on which the commit was made?

Yes, but can I ask what are you trying to achieve? My first answer would be to persuade you to use a different Triggering strategy, like "Poll repository for changes", and use PlanBranches feature in Bamboo - like you probably have now. So the only difference would be that the Bamboo actively asks Bitbucket if there are new changes, instead of Bitbucket being the 'active' party informing Bamboo.

But I'm not sure if this is what you're trying to achieve. You say something about triggering builds on \*different\* plans - why do you need \*different\* Bamboo Plans per your git branch?


author: Felipe Reis
body: Piotr,

Your last comment lead me straight to the problem cause. I'm using bitbucket as my GIT repo, so I didn't have to write any hook myself. Bitbucket has a simple configuration to enable commit triggered builds. I just have to type in my bamboo instance address, user, password and **build plan key**. So I have type my master build plan key, which is BPII-PII. So, it doesn't matter which branch was commited, Bitbucket will always tell Bamboo to build plan BPII-PII.

That leads me to a different question... Is it possible to configure Bamboo+Bitbucket in a way that commits trigger builds on different plans, according to the branch on which the commit was made?

Cheers!


author: PiotrA
body: Hm... how is your hook in the git repo configured? I mean, if you're using "Repository triggers the build..." Trigger, then you had to explicit set up git post-something-hook in your upstream git repository. How did you set it up?

I'm wondering if these hooks could be set up in a way that changes to both branches (master and to PII-25) would 'ping' the same URL in Bamboo, the one responsible for performing build of master plan. Care to shed some light as to how is your hooks set up?


author: Felipe Reis
body: I know Piotr,

I really don't know what I did wrong.

My trigger is of type "Repository triggers the build when changes are commited" on the master (main) plan. The branch plan inherits the same configuration, since the "Change trigger" option on the branch configuration is unchecked.

thanks for your comment.


author: PiotrA
body: Hi Felipe,

That's weird - certainly Bamboo should build a branch PII-25 not the main plan if the commits are on PII-25 branch. What is your plan Triggers configuration?


Tags: branch