Skip to main content
Version: Next

Bitbucket Cloud Discovery

The Bitbucket Cloud integration has a special entity provider for discovering catalog files located in Bitbucket Cloud. The provider will search your Bitbucket Cloud account and register catalog files matching the configured path as Location entity and via following processing steps add all contained catalog entities. This can be useful as an alternative to static locations or manually adding things to the catalog.

Installation

You will have to add the entity provider in the catalog initialization code of your backend. The provider is not installed by default, therefore you have to add a dependency to @backstage/plugin-catalog-backend-module-bitbucket-cloud to your backend package.

From your Backstage root directory
yarn --cwd packages/backend add @backstage/plugin-catalog-backend-module-bitbucket-cloud

Installation with New Backend System

// optional if you want HTTP endpoints to receive external events
// backend.add(import('@backstage/plugin-events-backend'));
// optional if you want to use AWS SQS instead of HTTP endpoints to receive external events
// backend.add(import('@backstage/plugin-events-backend-module-aws-sqs'));
backend.add(import('@backstage/plugin-events-backend-module-bitbucket-cloud'));
backend.add(import('@backstage/plugin-catalog-backend-module-bitbucket-cloud'));

You need to decide how you want to receive events from external sources like

Further documentation:

Installation with Legacy Backend System

Please follow the installation instructions at

Additionally, you need to decide how you want to receive events from external sources like

Set up your provider

packages/backend/src/plugins/catalog.ts
import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
import { BitbucketCloudEntityProvider } from '@backstage/plugin-catalog-backend-module-bitbucket-cloud';

import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
const builder = await CatalogBuilder.create(env);
const bitbucketCloudProvider = BitbucketCloudEntityProvider.fromConfig(
env.config,
{
auth: env.auth,
catalogApi: new CatalogClient({ discoveryApi: env.discovery }),
events: env.events,
logger: env.logger,
scheduler: env.scheduler,
},
);
builder.addEntityProvider(bitbucketCloudProvider);
const { processingEngine, router } = await builder.build();
await processingEngine.start();
return router;
}

Attention: catalogApi and tokenManager are required at this variant compared to the one without events support.

Configuration

To use the entity provider, you'll need a Bitbucket Cloud integration set up. Very likely a username and appPassword will be required (you are restricted to public repositories and a very low rate limit otherwise).

Additionally, you need to configure your entity provider instance(s):

app-config.yaml
catalog:
providers:
bitbucketCloud:
yourProviderId: # identifies your ingested dataset
catalogPath: /catalog-info.yaml # default value
filters: # optional
projectKey: '^apis-.*$' # optional; RegExp
repoSlug: '^service-.*$' # optional; RegExp
schedule: # same options as in SchedulerServiceTaskScheduleDefinition
# supports cron, ISO duration, "human duration" as used in code
frequency: { minutes: 30 }
# supports ISO duration, "human duration" as used in code
timeout: { minutes: 3 }
workspace: workspace-name

Note: It is possible but certainly not recommended to skip the provider ID level. If you do so, default will be used as provider ID.

  • catalogPath (optional): Default: /catalog-info.yaml. Path where to look for catalog-info.yaml files. When started with /, it is an absolute path from the repo root. It supports values as allowed by the path filter/modifier at Bitbucket Cloud's code search.
  • filters (optional):
    • projectKey (optional): Regular expression used to filter results based on the project key.
    • repoSlug (optional): Regular expression used to filter results based on the repo slug.
  • schedule:
    • frequency: How often you want the task to run. The system does its best to avoid overlapping invocations.
    • timeout: The maximum amount of time that a single task invocation can take.
    • initialDelay (optional): The amount of time that should pass before the first invocation happens.
    • scope (optional): 'global' or 'local'. Sets the scope of concurrency control.
  • workspace: Name of your organization account/workspace. If you want to add multiple workspaces, you need to add one provider config each.