Was not able to determine current branch for branch plug-in mode
Asked by Kia Armani:

Hello there,

I am trying to setup the branching feature in Bamboo for our repository, but I am running into issues with running automated builds.

The first automated build worked, but every build after that one results in this exception:

```
java.lang.IllegalStateException: Was not able to determine current branch for branch plug-in mode	at ch.mibex.bamboo.sonar4bamboo.tasks.SonarRuntimeDataProvider$$anonfun$setBranchTargetName$1.apply(SonarRuntimeDataProvider.scala:148)	at ch.mibex.bamboo.sonar4bamboo.tasks.SonarRuntimeDataProvider$$anonfun$setBranchTargetName$1.apply(SonarRuntimeDataProvider.scala:143)	at scala.Option.foreach(Option.scala:256)	at ch.mibex.bamboo.sonar4bamboo.tasks.SonarRuntimeDataProvider.setBranchTargetName(SonarRuntimeDataProvider.scala:143)	at ch.mibex.bamboo.sonar4bamboo.tasks.SonarRuntimeDataProvider.populateRuntimeTaskData(SonarRuntimeDataProvider.scala:51)	at com.atlassian.bamboo.chains.ChainPluginSupportHelper.lambda$prepareRuntimeTaskData$0(ChainPluginSupportHelper.java:37)	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)	at com.atlassian.bamboo.chains.ChainPluginSupportHelper.prepareRuntimeTaskData(ChainPluginSupportHelper.java:31)	at com.atlassian.bamboo.chains.ChainPluginSupportImpl$10.run(ChainPluginSupportImpl.java:242)	at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:174)	at com.atlassian.bamboo.variable.CustomVariableContextRunnerImpl.execute(CustomVariableContextRunnerImpl.java:31)	at com.atlassian.bamboo.chains.ChainPluginSupportImpl.buildStarted(ChainPluginSupportImpl.java:233)	at sun.reflect.GeneratedMethodAccessor1949.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:497)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)	at org.springframework.orm.hibernate5.support.OpenSessionInterceptor.invoke(OpenSessionInterceptor.java:90)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)	at com.sun.proxy.$Proxy242.buildStarted(Unknown Source)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.dispatchBuildsInCurrentStage(ChainExecutionManagerImpl.java:883)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.access$2000(ChainExecutionManagerImpl.java:127)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl$4.run(ChainExecutionManagerImpl.java:625)	at io.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:302)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.execute(ChainExecutionManagerImpl.java:581)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.tryStartChainState(ChainExecutionManagerImpl.java:340)	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.delayedStart(ChainExecutionManagerImpl.java:232)	at sun.reflect.GeneratedMethodAccessor1743.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:497)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)	at com.sun.proxy.$Proxy225.delayedStart(Unknown Source)	at sun.reflect.GeneratedMethodAccessor1743.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:497)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206)	at com.sun.proxy.$Proxy225.delayedStart(Unknown Source)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.lambda$call$0(PlanExecutionManagerImpl.java:374)	at com.atlassian.bamboo.util.CacheAwareness$3.call(CacheAwareness.java:136)	at com.atlassian.bamboo.util.CacheAwareness$3.call(CacheAwareness.java:133)	at com.atlassian.bamboo.util.CacheAwareness.withValuesOlderThanTimestampReloaded(CacheAwareness.java:162)	at com.atlassian.bamboo.util.CacheAwareness.withValuesOlderThanTimestampReloaded(CacheAwareness.java:133)	at com.atlassian.bamboo.util.CacheAwareness.withValuesOlderThanTimestampReloaded(CacheAwareness.java:187)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.call(PlanExecutionManagerImpl.java:373)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.call(PlanExecutionManagerImpl.java:366)	at io.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:293)	at com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl.lock(PlanExecutionLockServiceImpl.java:75)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.doWithProcessLock(PlanExecutionManagerImpl.java:655)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.access$400(PlanExecutionManagerImpl.java:130)	at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1.run(PlanExecutionManagerImpl.java:362)	at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)	at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)	at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)	at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)	at java.lang.Thread.run(Thread.java:745)
```


Answers:
author: Michael R?egg _Mibex Software_
body: Hi,

This error normally comes up when you have enabled incremental mode and/or the QG status build breaker feature, but do not use a Bitbucket Server repository in your build plan.

Is that possible?

Best regards,  
Michael (app vendor)

comments: author: Kia Armani
body: I do not use incremental mode, but I use the QG status build breaker feature. The build plan contains two repositorys from a Bitbucket Server.


author: Michael R?egg _Mibex Software_
body: [@Kia Armani](/t5/user/viewprofilepage/user-id/2328799)Thanks for your feedback. Could you please create a support request at <https://support.mibexsoftware.com> including the [debug logs of the app](https://mibexsoftware.atlassian.net/wiki/spaces/MSS/pages/764215385/How+to+enable+debug+logging+for+Bamboo+apps)? That would help us a lot in reproducing the issue.


author: Foong
body: The error happens at the Sonar task.

Contact the developer of the Sonar add-on [here](https://marketplace.atlassian.com/apps/1212756/sonar-for-bamboo?hosting=server&tab=support)