Skip to main content

Bitbucket

CatalogGitOpsScorecards

Summary

Bitbucket is a Git-based VCS from Atlassian. You can use Bitbucket to drive insights into values such as:

  • Repository details in the Catalog
  • Scorecard rules

The Bitbucket integration can also be used to power Cortex with GitOps.

Setup

Bitbucket Cloud

When using Bitbucket Cloud, you can use our official Bitbucket App, which can be found under Settings → Bitbucket.

Multi-account support

The Bitbucket integration has multi-account support so you can add a configuration for each additional instance by repeating the above process.

Each configuration requires an alias, which Cortex uses to correlate the designated instance with registrations for various entities. Registrations can also use a default configuration without a listed alias.

You can edit aliases and default configurations from the Bitbucket page in Settings. Select the edit icon next to a given configuration and toggle "Set as default" on. If you only have one configuration, it will automatically be set as the default.

caution

If you do not see the settings page you're looking for, you likely don't have the proper permissions and need to contact your admin.

Bitbucket Server and Data Center

caution

If you're using a self-hosted instance of Bitbucket, you'll need to verify that your Cortex instance is able to reach the Bitbucket instance.

We route our requests through a static IP address. Reach out to support at help@cortex.io to receive details about our static IP. If you're unable to directly allowlist our static IP, you can route requests through a secondary proxy in your network that has this IP allowlisted and have that proxy route traffic to your Bitbucket instance.

Basic authentication

If running a self-hosted Bitbucket instance, you can use basic auth to connect to Bitbucket. Add your Bitbucket host, username, and password under Settings → Bitbucket by selecting On-Prem (Basic Auth) in the dropdown.

We recommend setting up a bot account that has the desired access levels for the user.

OAuth authentication

If running a self-hosted Bitbucket instance (requires Bitbucket Server or Data Center version 7.20 or higher) you can also use OAuth to connect to Bitbucket. In order to do so, you will need to follow these steps to set up an application link:

  • In your Bitbucket server go to the Settings -> System -> Application Links -> Create Link
  • For the application type pick "External Application" and for the direction select "Incoming"
  • For the redirect url, put in the url of your Cortex instance and /oauth/internal/bitbucket for default configuration or the url of your Cortex instance and /oauth/internal/bitbucket/{accountAlias} for the non-default configuration
  • For the Permission, select "Projects: Admin" and click save
  • Copy the client ID and client secret for the created link

Once the link is created, add your Bitbucket host, client ID, and client secret under Settings → Bitbucket by selecting On-Prem (OAuth) in the dropdown and filling out the form.

Registration

Entity descriptor

Git

By specifying the x-cortex-git field in your Cortex entity descriptor, you'll be able to see Git information in the entity page, including the top language, recent commits, and top contributors.

x-cortex-git:
bitbucket:
repository: <workspace>/<repo>
basepath: myService # optional
alias: myApp # optional
FieldDescriptionRequired
repositoryorg/repo as defined in Bitbuckettrue
basepathIf the entity is in a monorepo (e.g. in a subdirectory), use this field to define the subdirectoryfalse
aliasAlias is optional and only relevant if you have opted into multi account supportfalse

The value for repository should be the workspace/repo as defined in Bitbucket.

Troubleshooting

  1. Rules are failing saying that I don't have file x, but it's definitely there!
    1. We always use the default branch for file existence checks. Make sure that the file is present in the default branch.