Skip to content

Get code intelligence and run Sourcegraph extensions on Bitbucket Server.

License

Notifications You must be signed in to change notification settings

sourcegraph/bitbucket-server-plugin

Repository files navigation

Sourcegraph for Bitbucket Server

The Sourcegraph plugin for Bitbucket Server communicates with your Sourcegraph instance to add code intelligence to your Bitbucket Server code views and pull requests.

The plugin also has the optional functionality to enable faster ACL permission syncing between Sourcegraph and Bitbucket Server and can add webhooks with configurable scope to Bitbucket Server.

Installation and Usage

Prerequisites

  1. You must have a Cloud or self-hosted Sourcegraph instance set up on v3.6 or higher.
  2. Your Sourcegraph instance should have a Bitbucket Server code host connection configured.
  3. The corsOrigin property should be set in site configuration to include the URL of your Bitbucket Server instance. Example value:
    "corsOrigin": "https://bitbucket.example.com"

Installation

  1. Log into your Bitbucket instance as an admin.
  2. Click the admin dropdown and choose Add-ons.
  3. Click Find new apps or Find new add-ons from the left-hand side of the page.
  4. Locate "Sourcegraph for Bitbucket" via search.
  5. Click Install to download and install your app.

Via file upload

  1. Log in to Bitbucket Server as an admin.
  2. Navigate to the Bitbucket admin page.
  3. Go to Add-ons > Manage apps.
  4. Click Upload app
  5. In the From this URL field, paste the following URL:
https://storage.googleapis.com/sourcegraph-for-bitbucket-server/latest.jar

Updating

Via the Atlassian marketplace

Installing the Sourcegraph for Bitbucket Server via the Atlassian marketplace will automatically update the plugin to the latest version, if enabled, and offer new versions to administrators in the UI.

Via file upload

Follow the steps in Installation.

Configuration

After installing the Sourcegraph for Bitbucket Server, you need to configure it to point to your Sourcegraph instance.

  1. On Bitbucket, go to the Administration page
  2. Find the Sourcegraph entry under Add-ons:

Add-ons

  1. On the Sourcegraph Settings page, set the Sourcegraph URL to the URL of your Sourcegraph instance:

Sourcegraph settings

Usage

Native code intelligence

Once configured, Sourcegraph for Bitbucket Server will add code intelligence hovers to code views and pull requests for all users that are logged in to your self-hosted Sourcegraph instance. It will also add links to view repositories, files and diffs on Sourcegraph.

Code intelligence

Additionally, activated Sourcegraph extensions will be able to add information to Bitbucket server code views and pull requests, such as test coverage data or trace/log information.

If a user is not logged in to Sourcegraph, they will still see the "View Repository on Sourcegraph" links, but code intelligence hovers as well as any data contributed by Sourcegraph extensions will not be displayed.

Webhooks

Go to Administration > Add-ons > Sourcegraph to see a list of all configured webhooks and to create a new one.

See the webhooks/README.md for more details.

Faster permissions fetching

Sourcegraph for Bitbucket Server adds two REST endpoints to provide more efficient endpoints for fetching permissions data:

  • /permissions/repositories?user=<USERNAME>&permission=<PERMISSION_LEVEL>
    Returns a list of repository IDs the given user has access to on the given permission level.
  • /permissions/users?repository=<REPO>&permission=<PERMISSION_LEVEL>
    Returns a list of user IDs that have access to the given repository on the given permission level.

The lists returned by both endpoints are encoded as Roaring Bitmaps.

About

Get code intelligence and run Sourcegraph extensions on Bitbucket Server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published