I've been trying out Bamboo OnDemand to get a sense for how automatic branch merging works, but I haven't been able to get it to ever work correctly. I made a simple repo on Bitbucket, put a simple maven prototype project into it and got it built. Then, I checked a simple failing test in called testBreaksInFeature into a branch called feature. I checked in an extra comment to master. The feature branch's build started failing in Bamboo, as expected, and the master branch did not. All good so far.
Next, I turned on branch merging, using Gatekeeper, and ran the build again. This time, to my surprise the build worked: no failing test. I logged into the elastic instance, sudo'ed up, and found the working directory for the job. Weirdly, git status revealed that the current branch was feature, and the staged changes in the directory were a deletion of the new test in the feature branch plus the addition of the comment from master. In other words, rather than being a merge from feature to master, it was a changeset that just turned feature into what master already had.
I was trying to figure out what was going on, so I replaced /usr/bin/git with a script that would log every call to git and then pass through to the real git. I found that Bamboo was calling the following sequence of commands:
I ran this sequence of commands in the working directory on the elastic instance, and then ran git status. That showed that I was still on master, and the staged changes were a clean merge from feature, failing test and all. But when I run the build with Gatekeeper, the working directory instead ends up on feature branch with bad changes staged that get rid of all feature changes.
What could be going on here? I set the elastic instance to have a git capability of /usr/bin/git, which I presume is right. I've logged all calls to that version of git, but the build's sequence of calls to /usr/bin/git works just fine when you run it manually.
Is Bamboo somehow using a combination of command line git and JGit in a way that's screwing up? How is my repo getting in this state before the build?