Branch specific build triggers

Hi there,

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

Cheers

5 answers

1 accepted

4 votes

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. (https://groups.google.com/forum/#!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...

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.

Armen

There are no separate triggeres for branch plans

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

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 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.

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

Thanks.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

683 views 0 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot