issue with adding cloud bitbucket repository to build plan on self-hosted bamboo
Asked by yuryf:

While adding a new repository to existing build plan (with existing repositories) I was faced with the issue that "Test connection" button results in "**We couldn't connect to the repository. The details you provided were invalid** ." and also under the "Username" input field a messages appears stating "**Invalid username.**" which doesn't make much sense to me as with this credentials I'm able to see repositories in the dropdown.

After realizing there is an issue with new repository I tried to "Test Connection" with existing repositories and it results in the same behavior, even though last repository was added just few days ago without problems.

Also, when I run the build (with checkouts from existing repositories) it runs successfully, so the credentials by fact are correct.

In logs nothing interesting

![bamboo issue.PNG](/t5/image/serverpage/image-id/56302iA7BA5C0C35AC8F0C/image-dimensions/489x517?v=v2 "bamboo issue.PNG")

![bamboo issue 2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/56306i43E283349DD8787B/image-size/large?v=v2&px=999 "bamboo issue 2.PNG")


Answers:
author: Ellie Z _they_them_
body: Hi [@yuryf](/t5/user/viewprofilepage/user-id/1517201) and [@Matt Hubble](/t5/user/viewprofilepage/user-id/1082738) ,

Thank you so much for reaching out to the Atlassian Community.

The Bitbucket Cloud REST APIs were recently updated to comply with GDPR privacy regulations. Part of these updates removed a variable containing information that Bamboo expects in the JSON response from Bitbucket.

This change resulted in the creation of new Linked repositories of type "Bitbucket Cloud" failing with 401 (Unauthorized) exceptions. You may see an "Invalid username" error message in the Bamboo UI, errors in the logs, or issues with the repository lists populating.

As a workaround, we recommend creating Linked repositories of type **[Git](https://confluence.atlassian.com/bamboo/git-289277007.html)** or **[Mercurial](https://confluence.atlassian.com/bamboo/mercurial-289277014.html)** to connect to your **[Bitbucket Cloud](https://confluence.atlassian.com/bamboo/bitbucket-cloud-289277000.html)** repositories.

For more information, please follow our public bug report:

* [BAM-20455 - Cannot save Bitbucket cloud repository](https://jira.atlassian.com/browse/BAM-20455)

We have been working with the Bamboo developers to create a hotfix for this issue, which we expect will be ready next week.

We sincerely apologize for any inconvenience this may cause. Please let me know if you have any questions or concerns.

Thanks,  
Elias Zeidan \| Bamboo Senior Support Engineer

comments: author: yuryf
body: Hi Elias

Thank you for confirming it's not on our side - we scratched our heads too intensively trying to understand what's going on.

For the workaround - I've added the repo as git and looks like working, but will need to test more on Monday.

Have a good day

\`Yury


author: Matt Hubble
body: I'm seeing the same issue, but in atlassian-bamboo.log I see this when I hit test connection

```
2019-05-31 12:55:24,557 WARN [http-nio-80-exec-18] [RESTCall] Response from GET https://api.bitbucket.org/2.0/teams/<shared credentials account name>/ (404)
```

The shared credentials account is correct as I'm able to use it to list out repos and branches, but test connection fails and then the repository won't save.

comments: author: toniq-dave
body: Did you ever resolve this? We've got the same problem, same error in logs and we can see the repos/branches, but can't save a new repo.


author: NoOne
body: I have the same issue.


author: Ellie Z _they_them_
body: Hi [@toniq-dave](/t5/user/viewprofilepage/user-id/8816) and [@Sergio Giuffrida](/t5/user/viewprofilepage/user-id/1856532) ,

Thanks for your comments! This looks like a new issue related to Bitbucket Cloud API updates. We've published a new Article about this issue which can be found here:

* [Using Bamboo with new Bitbucket Cloud authentication](https://community.atlassian.com/t5/Bamboo-articles/Using-Bamboo-with-new-Bitbucket-Cloud-authentication/ba-p/1358976)

Bitbucket Cloud now uses the Workspaces API, and requires use of the Bitbucket username instead of email address for authentication.

[@Matt Hubble](/t5/user/viewprofilepage/user-id/1082738) the error logs from the more recent issue match what you posted in your comment. Is the \<shared credentials account name\> an email address? If you are able to upgrade, Bamboo 6.10.6 and 7.0.3 use the new Workspace API by default.

I hope this helps!

Cheers,  
Elias \| Bamboo Senior Support Engineer


Tags: atl-bam-20455

bitbucket-cloud