Bamboo 4.0 Gatekeeper Auto-merging Conflict
Asked by Chuck Clelland:

Hi all,

Using Bamboo 4.0 Build 2906 on CentOS 6 box connected to our internal Github Enterprise server.

Have successfully setup Automatic Branch Detection for Story branches but hit a snag. Made a simple change to a README file and when Bamboo tries to merge, it gives us an Auto-merging CONFLICT (see images).

I know there are no conflicts: a) I'm the only one working on it and b) I did a 'git pull' before doing the 'git push'

```
$ git branch -a* S-001_Story-A  master  remotes/origin/HEAD -&gt; origin/master  remotes/origin/S-001_Story-A  remotes/origin/master$ git status# On branch S-001_Story-Anothing to commit (working directory clean)
```

Any ideas what might be going wrong here?

Thanks!

Here's the bamboo.log file output:

```
INFO   | jvm 1    | 2012/04/12 16:47:49 | 2012-04-12 16:47:49,601 INFO [3-BAM::PlanExec:pool-6-thread-2] [ChangeDetectionListenerAction] Change detection found 1 change for plan TA-CORE0INFO   | jvm 1    | 2012/04/12 16:47:49 | 2012-04-12 16:47:49,749 INFO [3-BAM::PlanExec:pool-6-thread-2] [ChainExecutionManagerImpl] Doing the merge before the first stageINFO   | jvm 1    | 2012/04/12 16:47:49 | 2012-04-12 16:47:49,752 INFO [3-BAM::PlanExec:pool-6-thread-2] [BranchIntegrationHelper] Checking out code from TA-CORE1, revision 739d8015b69a104885d9c841756ed75e8d1bd500INFO   | jvm 1    | 2012/04/12 16:47:51 | 2012-04-12 16:47:51,203 INFO [3-BAM::PlanExec:pool-6-thread-2] [BranchIntegrationHelper] Merging code from TA-CORE0, revision 5068da2af76e17ce93b0b0fc77ea603228ca632aINFO   | jvm 1    | 2012/04/12 16:47:52 | 2012-04-12 16:47:52,330 WARN [3-BAM::PlanExec:pool-6-thread-2] [ChainExecutionManagerImpl] Exception during merge: command [/usr/bin/git, merge, --no-commit, 5068da2af76e17ce93b0b0fc77ea603228ca632a] failed with code 1. Working directory was [/home/bamboo/bamboo-home/xml-data/build-dir/serverSide/TA-CORE0-5/mergeWorkspace]. stderr: Auto-merging README.mdCONFLICT (content): Merge conflict in README.mdAutomatic merge failed; fix conflicts and then commit the result. stdout: Auto-merging README.mdCONFLICT (content): Merge conflict in README.mdAutomatic merge failed; fix conflicts and then commit the result.INFO   | jvm 1    | 2012/04/12 16:47:52 | com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git, merge, --no-commit, 5068da2af76e17ce93b0b0fc77ea603228ca632a] failed with code 1. Working directory was [/home/bamboo/bamboo-home/xml-data/build-dir/serverSide/TA-CORE0-5/mergeWorkspace]. stderr: Auto-merging README.mdCONFLICT (content): Merge conflict in README.mdAutomatic merge failed; fix conflicts and then commit the result. stdout: Auto-merging README.mdCONFLICT (content): Merge conflict in README.mdAutomatic merge failed; fix conflicts and then commit the result.INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:240)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runMergeCommand(GitCommandProcessor.java:256)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.merge(NativeGitOperationHelper.java:220)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plugins.git.GitRepository.mergeWorkspaceWith(GitRepository.java:503)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.branch.BranchIntegrationHelper.merge(BranchIntegrationHelper.java:104)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.doVcsMerge(ChainExecutionManagerImpl.java:746)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.access$300(ChainExecutionManagerImpl.java:88)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl$1.run(ChainExecutionManagerImpl.java:378)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.execute(ChainExecutionManagerImpl.java:361)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.start(ChainExecutionManagerImpl.java:174)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.lang.reflect.Method.invoke(Method.java:601)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at $Proxy81.start(Unknown Source)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.lang.reflect.Method.invoke(Method.java:601)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at $Proxy82.start(Unknown Source)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.startWithLockTaken(PlanExecutionManagerImpl.java:249)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.access$100(PlanExecutionManagerImpl.java:40)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1.call(PlanExecutionManagerImpl.java:236)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1.call(PlanExecutionManagerImpl.java:230)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:324)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl.lock(PlanExecutionLockServiceImpl.java:68)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.doWithProcessLock(PlanExecutionManagerImpl.java:360)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.start(PlanExecutionManagerImpl.java:229)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.NonBlockingPlanExecutionServiceImpl$1.call(NonBlockingPlanExecutionServiceImpl.java:70)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plan.NonBlockingPlanExecutionServiceImpl$1.call(NonBlockingPlanExecutionServiceImpl.java:61)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:50)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at java.lang.Thread.run(Thread.java:722)INFO   | jvm 1    | 2012/04/12 16:47:52 | Caused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 1INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.utils.process.PluggableProcessHandler.complete(PluggableProcessHandler.java:83)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.utils.process.ExternalProcess.finish(ExternalProcess.java:366)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.utils.process.ExternalProcess.execute(ExternalProcess.java:409)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:235)INFO   | jvm 1    | 2012/04/12 16:47:52 | 	... 42 moreINFO   | jvm 1    | 2012/04/12 16:47:52 | 2012-04-12 16:47:52,332 WARN [3-BAM::PlanExec:pool-6-thread-2] [ChainExecutionManagerImpl] Unable to merge TA-CORE0-5 merge result: MergeResultSummaryImpl{integrationStrategy='GATE_KEEPER', mergeState='FAILED', pushState='NOT_ATTEMPTED', failureReason='Merge command error: Auto-merging README.mdCONFLICT (content): Merge conflict in README.mdAutomatic merge failed; fix conflicts and then commit the result.', integrationBranchVcsKey='739d8015b69a104885d9c841756ed75e8d1bd500', mergeResultVcsKey='null', integrationRepositoryId=7569411, integrationRepositoryBranchName='master', branchTargetVcsKey='5068da2af76e17ce93b0b0fc77ea603228ca632a', branchName='S-001_Story-A'}INFO   | jvm 1    | 2012/04/12 16:47:52 | 2012-04-12 16:47:52,391 ERROR [3-BAM::PlanExec:pool-6-thread-2] [ChainExecutionManagerImpl] Failed to merge for plan-result: TA-CORE0-5. Merge command error: Auto-merging README.mdCONFLICT (content): Merge conflict in README.mdAutomatic merge failed; fix conflicts and then commit the result.INFO   | jvm 1    | 2012/04/12 16:47:52 | 2012-04-12 16:47:52,391 INFO [3-BAM::PlanExec:pool-6-thread-2] [ChainExecutionManagerImpl] Plan TA-CORE0-5: Test Application - Before Commit - S-001_Story-A has finished executingINFO   | jvm 1    | 2012/04/12 16:47:52 | 2012-04-12 16:47:52,440 INFO [3-BAM::PlanExec:pool-6-thread-2] [DefaultBuildResultsIndexer] Indexed TA-CORE0-5, took: &lt; 1 secondINFO   | jvm 1    | 2012/04/12 16:47:52 | 2012-04-12 16:47:52,441 INFO [3-BAM::PlanExec:pool-6-thread-2] [DashboardCacheListener] event: com.atlassian.bamboo.event.ChainCompletedEvent[source=com.atlassian.bamboo.chains.ChainExecutionManagerImpl@299ae210] plan=TA-CORE0
```

![](../../upfiles/merge-conflict.png)


Answers:
author: Chuck Clelland
body: We finally have figured out that it was a combination of stumbling blocks for us. Not sure which one actually made things start working but the things to keep in mind when setting this up are:

1. Be sure that the Post-Receive service hook has the proper restful URL, we were putting in TA-CORE-JOB1, when it should have only been TA-CORE
2. We let our developers create the branches via Git bash, then configure configure them properly in Bamboo. We chose Gatekeeper approach, but be sure that the branches you want merged are in the correct order (see below), and
3. It's very important when using Github:enterprise that if you are using organizations to manage your repos, then you must setup the proper ACL's for the bamboo user that is going to do the merging. The conflict shown above we believe was legit, but when we retried everything we then received a r"eturn code 22fatal: git-http-push failed" (see below![](../../upfiles/CI-Merge.png)![](../../upfiles/Github-ACL.png)). Once the ACL was setup in Github:enterprise, the auto building and merging from branches all worked smoothly!


author: PiotrA
body: Any possibility you know how we can reproduce this issue locally? Maybe you can pass us your repo for examining (via <http://support.atlassian.com>) ?

Otherwise - can I look at the repository and branch configuration(s) of your plans: TA-CORE1, TA-CORE0? Also, what are these revisions: 739d8015b69a104885d9c841756ed75e8d1bd500, 5068da2af76e17ce93b0b0fc77ea603228ca632a? Can you describe their topology (or paste relevant 'git log' outputs)?

What happens if you manually run these commands (in a fresh, empty directory):

```
git initgit fetch YOUR_REPO mastergit fetch YOUR_REPO S-001_Story-Agit checkout 739d8015b69a104885d9c841756ed75e8d1bd500git merge --no-commit 5068da2af76e17ce93b0b0fc77ea603228ca632a
```

Will that succeed? Fail? With what error messages?