Bitbucket Server / Data Center Integration

Connect Codeveira to your self-hosted Bitbucket Server or Bitbucket Data Center instance to automatically open a code review on every push — using an HTTP access token and a webhook on the repo:refs_changed event.

Prerequisites

This guide covers self-hosted Bitbucket Server and Bitbucket Data Center. If you are using the cloud service at bitbucket.org, see the Bitbucket Cloud guide instead.

How Codeveira integrates with Bitbucket Server

Codeveira connects to your self-hosted Bitbucket Server or Data Center instance in two ways: a read-only REST API connection to fetch commit data, and a webhook to trigger code review creation automatically on every push.

Read-only API access

Codeveira authenticates using an HTTP access token (or username:password basic auth) against the Bitbucket Server REST API. Every API call is read-only — Codeveira never pushes code, creates pull requests, or modifies anything in your Bitbucket Server instance. The token is used to:

HTTP access tokens are the recommended credential type because they can be revoked independently, scoped to a single permission level, and do not require storing your account password. Codeveira only needs Repository: Read (or Projects: Read) permission.

Automatic review creation via webhooks

The webhook you configure in Step 4 fires a repo:refs_changed event on every push. Codeveira receives the event at /webhooks/bitbucket_server and:

  1. Reads the list of updated refs and their new commit SHAs from the event payload
  2. Fetches the commits introduced by the push via the Bitbucket Server REST API
  3. Groups consecutive commits by the same author into a single code review
  4. Creates the review, fetches the full diff, and stores it in Codeveira
  5. Sends email notifications to assigned reviewers and triggers the AI reviewer bot if configured
Both Codeveira and Bitbucket Server must be able to reach each other over the network. Codeveira makes outbound API calls to Bitbucket Server, and Bitbucket Server makes outbound webhook calls to Codeveira. Check your network rules if either direction is blocked.
1

Create an HTTP access token

HTTP access tokens are the recommended authentication method for Bitbucket Server. To create one:

  1. Click your avatar in the top-right corner of Bitbucket Server
  2. Go to Manage account
  3. Select HTTP access tokens in the left sidebar
  4. Click Create token
  5. Give it the name Codeveira
  6. Set permissions: Repository read (or Projects: read — both are sufficient)
  7. Click Create and copy the token immediately
Alternatively you can use username:password Basic auth — enter it in the same Token field as username:password. HTTP access tokens are preferred because they can be revoked independently without changing your account password.
2

Find your project key and repo slug

Bitbucket Server uses a project key and a repository slug to identify repositories. Both are visible in the repository URL:

https://bitbucket.example.com/projects/PROJ/repos/my-repo
  • Project key: PROJ — always uppercase, shown after /projects/
  • Repo slug: my-repo — shown after /repos/

In Codeveira the Path field must be PROJECTKEY/repo-slug, for example:

PROJ/my-repo

Project keys are case-sensitive and must be entered in uppercase exactly as they appear in the URL.

3

Add the repository in Codeveira

  1. Go to Repositories → New Repository
  2. Click the Bitbucket Server platform button
  3. Fill in the fields:
  • Name — display name for this repository in Codeveira
  • Instance URL (required) — base URL of your Bitbucket Server, e.g. https://bitbucket.example.com
  • PathPROJECTKEY/repo-slug, e.g. PROJ/my-repo
  • Token — HTTP access token from Step 1, or username:password

Click Save. Codeveira will immediately attempt a test API call to verify the credentials and path — after that, the first push will automatically open a code review.

4

Configure the webhook

Webhooks allow Codeveira to automatically create a code review on every push without polling.

  1. In Bitbucket Server, navigate to your repository
  2. Go to Repository settings → Webhooks → Create webhook
  3. Set the following values:
  • Name: Codeveira
  • URL: https://codeveira.yourdomain.com/webhooks/bitbucket_server
  • Secret: generate a secret and save it (see below)
  • Events: check Push (event key repo:refs_changed)

Generate a strong secret and set it in your .env:

openssl rand -hex 20
# Copy the output, then add to .env:
BITBUCKET_SERVER_WEBHOOK_SECRET=your_generated_secret

After updating .env, restart the application:

docker compose up -d app
Bitbucket Server sends an X-Hub-Signature header (HMAC-SHA256) when a secret is configured. Without BITBUCKET_SERVER_WEBHOOK_SECRET set in Codeveira, any payload is accepted — always set it in production to prevent spoofed events.

Troubleshooting

SSL certificate errors

Bitbucket Server installations often use a self-signed certificate. Codeveira's Docker container may reject it. Two options:

"Project not found" when saving a repository

The project key is case-sensitive and must be uppercase. Check the Bitbucket Server URL bar — the key appears in the path as /projects/PROJ/. A lowercase or partial match will result in a 404 from the API.

Webhook returns 401 Unauthorized

This means the HMAC signature does not match. The most common causes are:

Regenerate the secret, update both Bitbucket Server's webhook configuration and BITBUCKET_SERVER_WEBHOOK_SECRET, then restart: docker compose up -d app.

← All docs Next: Azure DevOps Integration →