gitopscli icon indicating copy to clipboard operation
gitopscli copied to clipboard

Is it possible to use with Bitbucket cloud?

Open UrosCvijan opened this issue 3 years ago • 4 comments

Is this posssible to work with bitbucket cloud? As I keep getting 403, like either my repository is not present or I don't have permissions, but I think I should be doing everything right.

So thinking as lot of thing are available for bitbucket server but not cloud, maybe this is the same?

Thanks

UrosCvijan avatar Nov 17 '22 11:11 UrosCvijan

Hey @UrosCvijan I think the API's are quite similar, you could try to set the URL to the cloud instance and try it out - we have not tested it yet.

joachimprinzbach avatar Dec 12 '22 12:12 joachimprinzbach

I don't have any experience with Bitbucket cloud, but I found some hints:

  1. According to https://community.atlassian.com/t5/Bitbucket-questions/Using-python-API-to-get-branch-restrictions-pullrequests/qaq-p/2072969 you have to use your username (not your email) + an app password (not your regular password) with enough priviliges. There are also links in the answer on how to create those.
  2. If that does not work, we might have to create the internal Bitbucket client instance differently. Looks like there is a special Cloud class: https://atlassian-python-api.readthedocs.io/index.html
from atlassian.bitbucket import Cloud

bitbucket = Cloud(
    username=bitbucket_email,
    password=bitbucket_password,
    cloud=True)

We're currently using the Bitbucket class: https://github.com/baloise/gitopscli/blob/a38a1c5848321528a732a994cb026795a8f10825/gitopscli/git_api/bitbucket_git_repo_api_adapter.py#L19

Please let us know if hint 1 worked :wink:

christiansiegel avatar Dec 13 '22 18:12 christiansiegel

Hi @christiansiegel ,

I will try. I think i even tried all the combinations but constantly was getting like permission denied error, if i have access or check if the repository exist. It was something like that. I think there is some difference what is organization in bitbucket server, cloud etc.. I mean, you dont have to change it for this use case, it would be nice. I will also try to push that we move to github as noticed for a lot of things bitbucket cloud does not have support or those other things dont have support for bitbucket cloud.

Thank you for the great tool btw.. .

UrosCvijan avatar Dec 13 '22 19:12 UrosCvijan

Hi @UrosCvijan ,

I played around with it: With the Bitbucket Cloud client of atlassian-python-api I could get it to work. So what needs to be done is

  1. Upgrade https://github.com/baloise/gitopscli/blob/f351bc4dc1047c04c1cb590e7e56e71f051edfba/setup.py#L13 to a more recent version with cloud support
  2. Implement the GitRepoApi interface for Bitbucket cloud using the aforementioned Cloud client

I started on branch feat/bitbucket-cloud. I marked all the remaining TODOs. Unfortunately I don't have much time these days. Anyone, feel free to take it from here..

christiansiegel avatar Dec 15 '22 19:12 christiansiegel