Authorization error when checking out Bitbucket repository with Bamboo OnDemand
Asked by ouchmyhead:

After following the actions identified in [Getting started with Bamboo OnDemand](https://confluence.atlassian.com/display/AOD/Getting+started+with+Bamboo+OnDemand), I am receiving an \`authorization failed\` error when I try and run my first build.

The error is thrown within a couple of seconds and occurs with the initial check out from Bitbucket. Bamboo gives the following error message:

```
Errors getting changes for $TEST_PLAN_KEY$(java.lang.RuntimeException : com.atlassian.bamboo.plugins.hg.HgCommandException: command /usr/bin/hg id -i --debug --rev default --config 'ui.ssh=ssh -o StrictHostKeyChecking=no -o BatchMode=yes' https://john_smith:********@bitbucket.org/teamName/repository failed. Working directory was `/data/jirastudio/bamboo/home/xml-data/build-dir/_hg-repositories-cache/850b1683c126cc786389ddf24f1fd10137908b4c'. stderr: abort: authorization failed stdout: using https://bitbucket.org/teamName/repository proxying through http://squid:3128 http auth: user john_smith, password ************************************************** sending capabilities command http auth: user john_smith, password ************************************************** http auth: user john_smith, password ************************************************** )
```

The credentials are correct as I am able to select the appropriate repository when creating a plan. I do have SSH set up on my account, but I am able to access my account using the credentials on other servers that do not have a certificate.

Can anyone point out where I am going wrong? I am finding this difficult to debug!

The full stacktrace provided by Bamboo is as follows:

```
java.lang.RuntimeException: com.atlassian.bamboo.plugins.hg.HgCommandException: command /usr/bin/hg id -i --debug --rev default --config 'ui.ssh=ssh -o StrictHostKeyChecking=no -o BatchMode=yes' https://john_smith:********@bitbucket.org/teamName/repository failed. Working directory was `/data/jirastudio/bamboo/home/xml-data/build-dir/_hg-repositories-cache/850b1683c126cc786389ddf24f1fd10137908b4c'. stderr: abort: authorization failed
 stdout: using https://bitbucket.org/teamName/repository
proxying through http://squid:3128
http auth: user john_smith, password **************************************************
sending capabilities command
http auth: user john_smith, password **************************************************
http auth: user john_smith, password **************************************************

 at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:132)
 at com.atlassian.bamboo.executor.RetryingTaskExecutor.runTask(RetryingTaskExecutor.java:88)
 at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:191)
 at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:176)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectionChangesWithRetry(DefaultChangeDetectionManager.java:469)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceLastBuildInternal(DefaultChangeDetectionManager.java:330)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceRevisions(DefaultChangeDetectionManager.java:258)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectChangesSinceRevisions(DefaultChangeDetectionManager.java:161)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectAllChangesSinceLastBuild(DefaultChangeDetectionManager.java:127)
 at com.atlassian.bamboo.v2.trigger.ManualBuildDetectionAction.performDelayedChangeDetection(ManualBuildDetectionAction.java:113)
 at com.atlassian.bamboo.chains.ChainExecutionManagerImpl$2.getChainState(ChainExecutionManagerImpl.java:199)
 at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.tryStartChainState(ChainExecutionManagerImpl.java:252)
 at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.delayedStart(ChainExecutionManagerImpl.java:189)
 at sun.reflect.GeneratedMethodAccessor2759.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy75.delayedStart(Unknown Source)
 at sun.reflect.GeneratedMethodAccessor2759.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
 at $Proxy76.delayedStart(Unknown Source)
 at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.call(PlanExecutionManagerImpl.java:300)
 at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1$1.call(PlanExecutionManagerImpl.java:296)
 at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:312)
 at com.atlassian.bamboo.plan.PlanExecutionLockServiceImpl.lock(PlanExecutionLockServiceImpl.java:77)
 at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.doWithProcessLock(PlanExecutionManagerImpl.java:467)
 at com.atlassian.bamboo.plan.PlanExecutionManagerImpl.access$200(PlanExecutionManagerImpl.java:48)
 at com.atlassian.bamboo.plan.PlanExecutionManagerImpl$1$1.run(PlanExecutionManagerImpl.java:295)
 at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:52)
 at java.lang.Thread.run(Thread.java:662)
Caused by: com.atlassian.bamboo.plugins.hg.HgCommandException: command /usr/bin/hg id -i --debug --rev default --config 'ui.ssh=ssh -o StrictHostKeyChecking=no -o BatchMode=yes' https://john_smith:********@bitbucket.org/teamName/repository failed. Working directory was `/data/jirastudio/bamboo/home/xml-data/build-dir/_hg-repositories-cache/850b1683c126cc786389ddf24f1fd10137908b4c'. stderr: abort: authorization failed
 stdout: using https://bitbucket.org/teamName/repository
proxying through http://squid:3128
http auth: user john_smith, password **************************************************
sending capabilities command
http auth: user john_smith, password **************************************************
http auth: user john_smith, password **************************************************

 at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.runCommand(HgCommandProcessor.java:519)
 at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.runCommand(HgCommandProcessor.java:482)
 at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.extractTipHash(HgCommandProcessor.java:544)
 at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.getRemoteTipForBranch(HgCommandProcessor.java:395)
 at com.atlassian.bamboo.plugins.hg.HgRepositoryAccessImpl.getLatestRemoteRevisionHash(HgRepositoryAccessImpl.java:325)
 at com.atlassian.bamboo.plugins.hg.HgRepositoryAccessImpl.collectChangesSinceLastBuild(HgRepositoryAccessImpl.java:95)
 at com.atlassian.bamboo.plugins.hg.HgRepository.collectChangesSinceLastBuild(HgRepository.java:379)
 at com.atlassian.bamboo.plugins.hg.BitbucketRepository.collectChangesSinceLastBuild(BitbucketRepository.java:282)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager$1.call(DefaultChangeDetectionManager.java:473)
 at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager$1.call(DefaultChangeDetectionManager.java:470)
 at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:108)
 ... 37 more
Caused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 255
 at com.atlassian.utils.process.PluggableProcessHandler.complete(PluggableProcessHandler.java:83)
 at com.atlassian.utils.process.ExternalProcess.finish(ExternalProcess.java:376)
 at com.atlassian.utils.process.ExternalProcess.execute(ExternalProcess.java:419)
 at com.atlassian.bamboo.plugins.hg.HgCommandProcessor.runCommand(HgCommandProcessor.java:515)
 ... 47 more
```

```
?
```


Answers:
author: ouchmyhead
body: Decided against using Bamboo and instead went back to using Jenkins.

I opened up a ticket with Atlassian support, and after 72 hrs - before ticket was marked as being investigated - the issue resolved itself and I could check out of the repositories with no authorization issues. I did not make any changes to the repository or the Bamboo Job, so this seems like it was a bug from the Atlassian side.

In regards to the ticket I opened with Atlassian, the issue was tagged by their dev team as a Bitbucket issue, however I am confident that it was Bamboo as I had no issues when checking out the repository using our Jenkins server.

Atlassian closed my support ticket as unresolved, so I do not believe that they made any direct changes from their side which resulted in this problem "fixing itself".


author: Martin Goldhahn
body: I had the same issue with a linked repository. When I opened the linked repository definition I saw that the repository was marked with some red text, some authorization error. I added the user name and password again, pressed "Load Repositories" and everything worked fine again.

It looks like Bamboo "forgot" the credentials for the repository.


author: AgentSmith
body: Unless you replaced **/teamName/repository** just for the sake of posting, you would need to specify the actual Bitbucket account and repository.

comments: author: ouchmyhead
body: Yes, the URL was replaced. The problem looks like it might be associated with having SSH enabled on my account. I am able to check out the same repository using a different account that does not have an associated SSH key


Tags: bitbucket-cloud

cloud