Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitbucket docs #207

Open
rickvandermeij-aanzee opened this issue Aug 14, 2023 · 12 comments
Open

Bitbucket docs #207

rickvandermeij-aanzee opened this issue Aug 14, 2023 · 12 comments

Comments

@rickvandermeij-aanzee
Copy link

How to setup bitbucket with docker. when running the command line, it says GITHUB.USER_TOKEN is required

@okotek
Copy link
Contributor

okotek commented Aug 14, 2023

Add -e CONFIG.GIT_PROVIDER=bitbucket

@anthony-maio
Copy link

Is this for bitbucket SERVER or cloud?

@mrT23
Copy link
Collaborator

mrT23 commented Sep 12, 2023

/similar_issue

@nevotheless
Copy link

The docs could be clearer on if this applies to bitbucket cloud only or can be used for bitbucket server / datacenter as well.
On-premise usage in general is not very well explained in the documentation.

@mrT23
Copy link
Collaborator

mrT23 commented Mar 14, 2024

The docs could be clearer on if this applies to bitbucket cloud only or can be used for bitbucket server / datacenter as well. On-premise usage in general is not very well explained in the documentation.

You are welcome to open a PR to improve the docs.
There are many git providers and sub-frameworks, and we rely on the community to cover so many options.

@anthony-maio
Copy link

anthony-maio commented Mar 15, 2024 via email

@calebAtIspot
Copy link

calebAtIspot commented Mar 15, 2024

I was also confused for a bit, because the documentation says it wants a "bearer token" but that name was not what I expected. After a bit I realized a repository access token will do.

If you use bitbucket cloud:

  1. Go to your repository settings
  2. Go to Access tokens under Security
  3. Create an access token. Give it the following scopes: pullrequest pullrequest:write repository repository:write
  4. In your terminal, save it as a environment variable. BITBUCKET_BEARER_TOKEN=<put-token-here>
  5. Save your openai api key as a environment variable OPENAI_API_KEY
  6. Run the bitbucket command listed in https://pr-agent-docs.codium.ai/installation/locally. I used docker run --rm -it -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=<pr_url> review , editing it to set the pr url.

You might get an error Failed to set review labels, error: 'NoneType' object is not iterable. Ignore that, you should still see a AI review comment in your PR.

@mbrambati
Copy link

I'm getting another error and chatGPT isn't helpful with it, can someone guide me please?

Traceback (most recent call last): File "/app/pr_agent/git_providers/__init__.py", line 57, in get_git_provider_with_context git_provider = _GIT_PROVIDERS[provider_id](pr_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/pr_agent/git_providers/$GIT_PROVIDER_provider.py", line 51, in __init__ self.set_pr(pr_url) File "/app/pr_agent/git_providers/$GIT_PROVIDER_provider.py", line 129, in set_pr self.workspace_slug, self.repo_slug, self.pr_num = self._parse_pr_url(pr_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/pr_agent/git_providers/$GIT_PROVIDER_provider.py", line 450, in _parse_pr_url raise ValueError( ValueError: The provided URL does not appear to be a Bitbucket PR URL The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/pr_agent/cli.py", line 94, in <module> run() File "/app/pr_agent/cli.py", line 88, in run result = asyncio.run(inner()) ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/app/pr_agent/cli.py", line 79, in inner result = await asyncio.create_task(PRAgent().handle_request(args.pr_url, [command] + args.rest)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/pr_agent/agent/pr_agent.py", line 57, in handle_request apply_repo_settings(pr_url) File "/app/pr_agent/git_providers/utils.py", line 14, in apply_repo_settings git_provider = get_git_provider_with_context(pr_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/pr_agent/git_providers/__init__.py", line 62, in get_git_provider_with_context raise ValueError(f"Failed to get git provider for {pr_url}") from e ValueError: Failed to get git provider for https://$GIT_PROVIDER.org/...

@anthony-maio
Copy link

anthony-maio commented Oct 15, 2024

can you show us the command line you tried to run? this isn't a bug but maybe i can show you the correct command

also please clarify if you are using bitbucket data center/server vs bitbucket cloud

@mbrambati
Copy link

mbrambati commented Oct 15, 2024

Sure, I'm using bitbucket cloud + pipelines

via standard config:

pull-requests:
  '**':
    - step:
        name: PR Agent Review
        image: python:3.10
        services:
          - docker
        script:
          - docker run -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=https://bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pull-requests/$BITBUCKET_PR_ID review

I'm wondering if it's the $BITBUCKET_PR_ID as if I change it by any PR ID (i.e: 1649) then the url seems to be fine and the review ends ok.

@mbrambati
Copy link

It's just fine, the manual test (trigger) fails but then the pipeline works just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@nevotheless @okotek @anthony-maio @mrT23 @rickvandermeij-aanzee @calebAtIspot @mbrambati and others