Auto-created Git branches always building in Bamboo
Asked by Paul Smith:

We've recently updated to Bamboo 4.4.3 and we're trying to use the automatic branch creation for Git. What we'd like ideally is for all pushes to the "master" branch to build automatically, but pushes to developer branches (for our purposes it's enough to say "not master") to only build when requested manually.

That was not an option, and by setting the trigger on the parent plan to build on each commit, which is what we used to do, all the branch plans also did this.

So, we changed the parent plan to use "Repository triggers the build", and added a trigger to our Git repository, that only requested a new build if the change went to the master branch. This is successful at having the master branch build on commit, so we know the trigger etc. is hooked up properly.

However, we're STILL seeing a build start every time a new branch is detected. Our builds take a long time, and it's not useful to run a build merely for starting a new branch in the Git repository: we tend to make a lot of small branches and this is causing our build servers to be constantly loaded with useless builds.

Is this a known problem? Is there a workaround? Or do we seem to be doing something wrong?

Cheers!


Answers:
author: Paul Smith
body: I filed the bug above. In the meantime what I've done is create a clone of the "main" plan, enable Git branches on the clone, and remove all triggers from the clone so that it will only run by manual request. Then I removed the branch auto-create capability from the original plan so it's still triggered by repo request but doesn't get new branches created.

This is kind of a drag, to have to maintain two different plans where I want identical behavior (if I make changes to one I'll have to remember to make those changes to the other as well) but the behavior is much more predictable. When the bug is fixed in Bamboo I'll revisit.

Cheers!


author: PiotrA
body: Hi Paul,

AFAIK this is a known limitation of Bamboo - and I think you will be interested in the <https://jira.atlassian.com/browse/BAM-12451> - this issue seems to be exactly what you would request Bamboo to have. So it might be a good idea if you place your vote on that issue (and add yourself as a watcher).

What would you say?

cheers!

comments: author: Paul Smith
body: Thanks for the note. I think that bug is *similar* to what I'm looking for, but that seems like an enhancement request, although a useful one. I think the behavior I'm observing is actually a bug. I'm happy enough with the supported method of only triggering a build when requested by the repository. That works well.

My problem is that it seems that builds are ALSO being kicked off automatically by Bamboo whenever a new branch is added to the plan. I don't want that, and it doesn't seem useful to me. If I set the trigger to "Repository triggers the build", then I don't expect Bamboo to ever trigger builds on its own. But it does.


author: PiotrA
body: Ah, so you would like to have the plan branches detected\&created, but without the initial build (#1) to be triggered by Bamboo (the one that has the "initial build" visible as a trigger reason, instead of "manual build" or "scheduled" or whatever trigger reason) ?

From what I see in Bamboo code it seems to me that this initial build is always triggered when a newly plan (or a branch!) created has at least one Trigger defined (so only "manually" triggered plans will have no initial builds for branches). I'm not sure if that's a bug or feature.

Anyway, I think it would be good idea if you would raise a bug issue on <https://jira.atlassian.com> for Bamboo project - it seems quite legit to be able configuring Bamboo whether it should or should not spin up the initial build for the auto-detected branches, especially if the main plan Trigger is something different than "Poll repository for changes".

Does this sound OK to you?


author: Paul Smith
body: Oh I see you wanted a Jira ticket not a support ticket. Oops. Should I refile? Or can you move it?


author: Paul Smith
body: OK I created <https://support.atlassian.com/browse/BSP-9451>

Thanks.

I have a new issue. As a test last night I created a new branch and the build was started, as we've discussed above. Then I pushed a commit to that branch and the build was not started, which was correct and expected since my trigger didn't fire on a private branch. I thought I understood what was going on and went to bed :-).

But then this morning (7 hours later), seemingly out of the blue, a build was started on my new branch! I have no idea why (I was not even in the office when it started). The build type shows "Changes by \<me\>". I did make changes, but it was 7 hours before AND the build type was set to "Repository triggers the build".

This is very curious. Should I file a separate bug about this? Are there logs somewhere on the Bamboo server, or something, that might give more details as to why it decided to start a build at that time?


author: PiotrA
body: BSP-9451 has been copied to BAM-12944


author: PiotrA
body: As for the second issue - you should have somewhere atlassian-bamboo.log file(s) on the Bamboo Server (where exactly? - you can check that via Bamboo-\>Admin-\>System Information page). They could contain information about code change detections/triggers. But I'm not 100% sure we're logging each occurence. Worth a try anyway.


author: Paul Smith
body: Thanks for the pointer. You were right, there's nothing in the log about why the build was started. Should I file a case about this as well?


author: PiotrA
body: Yup, that might be a good idea.


author: Paul Smith
body: Stefan, I can no longer seem to find BAM-12944 although I was pretty sure it was there when you first filed it. Maybe it got relinked to a different user account and I can't see it anymore? Or it got deleted? But I didn't get any email.


author: PiotrA
body: No idea. I've just checked and from my side it is still visible under the <https://jira.atlassian.com/browse/BAM-12944> url. I don't see any permission restrictions set up... so... perhaps it's yet another mysterious case for Sherlock Holmes?

edit: maybe it was intermittent? Can't you still access that issue?


Tags: branch

git