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

Branch specific build triggers

m_nayob97 February 10, 2013

Hi there,

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

Cheers

6 answers

4 votes
SGD
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 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.

Louis Burton June 23, 2014

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.

mguillermin March 16, 2016

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

Norman Atashbar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 23, 2018

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
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 8, 2021

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):

devops-automation-for-jira-bamboo-build

1 vote
Deleted user August 2, 2016

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.

1 vote
ArmenA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2013

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

SGD
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2013

There are no separate triggeres for branch plans

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

0 votes
hani_atalla March 28, 2014

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.

0 votes
aMarcus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 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.

m_nayob97 February 10, 2013

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
TAGS
AUG Leaders

Atlassian Community Events