Bitbucket
Run as a Bitbucket Pipeline¶
You can use the Bitbucket Pipeline system to run PR-Agent on every pull request open or update.
- Add the following file in your repository bitbucket-pipelines.yml
pipelines:
pull-requests:
'**':
- step:
name: PR Agent Review
image: codiumai/pr-agent:latest
script:
- pr-agent --pr_url=https://bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pull-requests/$BITBUCKET_PR_ID review
-
Add the following secure variables to your repository under Repository settings > Pipelines > Repository variables.
-
CONFIG__GIT_PROVIDER:
bitbucket
- OPENAI__KEY:
<your key>
- BITBUCKET__AUTH_TYPE:
basic
orbearer
(default isbearer
) - BITBUCKET__BEARER_TOKEN:
<your token>
(required when auth_type is bearer) - BITBUCKET__BASIC_TOKEN:
<your token>
(required when auth_type is basic)
You can get a Bitbucket token for your repository by following Repository Settings -> Security -> Access Tokens. For basic auth, you can generate a base64 encoded token from your username:password combination.
Note that comments on a PR are not supported in Bitbucket Pipeline.
Bitbucket Server and Data Center¶
Login into your on-prem instance of Bitbucket with your service account username and password.
Navigate to Manage account
, HTTP Access tokens
, Create Token
.
Generate the token and add it to .secret.toml under bitbucket_server
section
Run it as CLI¶
Modify configuration.toml
:
and pass the Pull request URL:
python cli.py --pr_url https://git.onpreminstanceofbitbucket.com/projects/PROJECT/repos/REPO/pull-requests/1 review
Run it as service¶
To run PR-Agent as webhook, build the docker image:
docker build . -t codiumai/pr-agent:bitbucket_server_webhook --target bitbucket_server_webhook -f docker/Dockerfile
docker push codiumai/pr-agent:bitbucket_server_webhook # Push to your Docker repository
Navigate to Projects
or Repositories
, Settings
, Webhooks
, Create Webhook
.
Fill the name and URL, Authentication None select the Pull Request Opened checkbox to receive that event as webhook.
The URL should end with /webhook
, for example: https://domain.com/webhook