Onboard Bitbucket repositories to Polaris applications

Black Duck Polaris Platform

This procedure describes how to onboard one or more Bitbucket repositories to new or existing Polaris applications. During this process, you'll have the option of importing all repositories in your Bitbucket instance or choosing specific projects to import.

Before you begin, review Integrate Bitbucket with Polaris. If you're using Bitbucket Data Center, that topic explains how to make sure Polaris has network access to your Bitbucket instance.

Important:

Bulk SCM integration with Bitbucket Cloud requires a Polaris Premium subscription.

Note: SCA Fix Pull Requests are supported for repositories hosted in Bitbucket Cloud and Bitbucket Data Center. For Bitbucket Data Center integrations, Polaris creates the pull request over the Secure Tunnel that connects it to your repository. See SCA Fix Pull Requests.

Bitbucket Data Center: Create an HTTP access token

Authentication between Bitbucket Data Center and Polaris uses an HTTP access token (personal access token) that you create in Bitbucket. Follow the steps below or the instructions in the Bitbucket Data Center documentation: HTTP access tokens > Create HTTP access tokens.

  1. Log in to Bitbucket Data Center.
  2. Select the profile icon (near the upper-right corner of the screen) and open Manage account.
  3. On the left tab, click HTTP access tokens and click Create token.
  4. Name your token.
  5. Set Project permissions to PROJECT_ADMIN.
    Note: The required repository permissions (Repository Admin) are automatically inherited from the project permissions.
  6. Set the token's expiration date. To avoid issues, we recommend Do not expire.
Important: Store your token in a secure location. Each time you modify an integration, you will need to reenter the token to save your changes.

Creating an API token

When integrating SCM repositories, you will need an API token you create in Bitbucket Cloud (Premium).

Authentication between Bitbucket Cloud and Polaris is managed with an API token that you create in Bitbucket Cloud. For additional information: Create an API token.

Important: Must be created in Bitbucket Cloud (Premium). Standard and Free versions does not allow users to create webhooks.
Important: Token must be created by a Bitbucket Cloud Organization Owner or users with the "Manage organization webhooks" permission, who are authorized to manage organization webhooks. Although other Bitbucket Cloud users may be able to select the scope requirements when creating a token, the token will not work due to permission requirements in Bitbucket to manage organization webhooks.
Note: App passwords have been deprecated for Bitbucket Cloud. Existing projects integrated using App Password will continue to work until the password expires or Atlassian ends support. After your App Password stops working or if creating a new integration, use API tokens.
  1. Select the Settings gear icon in the upper-right corner of the top navigation bar.
  2. Under Personal settings, select Atlassian account settings.
  3. From the Atlassian Account page, select the Security tab on the top navigation bar.
  4. Select Create and manage API tokens.
  5. Select Create API token with scopes.
  6. Give the API token a name and an expiry date. 365 days is recommended, select Next.
  7. Select Bitbucket as the app and select Next.
  8. Select the scopes:
    • read:user:bitbucket
    • read:webhook:bitbucket
    • read:workspace:bitbucket
    • read:project:bitbucket
    • read:repository:bitbucket
    • read:pullrequest:bitbucket
    • write:pullrequest:bitbucket
    • write:webhook:bitbucket


  9. Select Next.
  10. Select the Create token button.

    The page will display the New API token.

  11. Copy the generated API token and store it in a secure location.
    Important: Store your token in a secure location. Each time you modify a project's SCM integration, you'll need to reenter the token to save your changes.

Onboard Bitbucket repositories to Polaris applications

  1. On the Portfolio page, select + Create > New Application(s) with SCM.
  2. Connect to your SCM:
    1. Select the type of server hosting your repositories:
      • Cloud-hosted — for Bitbucket Cloud
      • Self-hosted — for Bitbucket Data Center
    2. Select Bitbucket.
    3. (Bitbucket Cloud only) Enter Email (Bitbucket Account Email).
    4. (Bitbucket Data Center only) Enter the SCM URL of your Bitbucket Data Center instance.
    5. (Bitbucket Data Center only) If you're using the Secure Tunnel, check URL is in a private network and select a secure tunnel from the pull-down menu (see Prerequisites).
    6. Enter your Bitbucket access token under Repository Access Token.
      Note: The access token provided here will be used to complete the onboarding process and will be subject to rate limits enforced by Bitbucket.
    7. Click Test Connection.

      You should receive a Connection Successful message and the Quick Start options should be visible. If your connection test is unsuccessful, check the following:

      • That your network connection is stable.
      • That the Repository Access Token is accurate.
      • That the Repository Access Token is still valid and has not expired.
      • That you selected the correct provider for your SCM.
      • That you have authorized the access token for use outside SSO (if applicable).
      • That the teleport agent (for example, Bridge) in the private network is running and pointing at the secure tunnel. See Add and manage secure tunnels in the Polaris UI.
  3. If your connection is successful, use the Select Method dropdown menu to select one of the following:
    • Automatically create Polaris Applications from BitBucket workspaces (Cloud) or Automatically create Polaris Applications from BitBucket projects (Data Center).

      Important:

      This first option will onboard every single repo in your SCM instance. Depending on the number of repos you have, this could take a significant amount of time and result in many unwanted projects. We recommend you choose the second option in most circumstances, especially when first testing this feature.

    • Manually map repositories to Polaris Applications (Cloud or Data Center)

    The name of each new Polaris project will be based on the originating workspace name (for Cloud) or project name (for Data Center) plus the originating repository name (for Cloud and Data Center).

    Note: Bitbucket Data Center does not support group-level webhook auto-discovery. Webhooks must be configured at the project or repository level in Bitbucket Data Center.

    If you selected the first option, skip ahead to step 7.

  4. Under the Projects heading, use the pull-down menu to browse and select one or more of the repos in your SCM instance.
    Important: You'll be mapping the selected repos to a single Polaris application. If you want to add some repos to a different application, deselect them for now.
  5. Using the radio buttons under the Application heading, choose whether you want to use a New or Existing Polaris application for the selected repos.
    • New - enter a unique, suitable name for the new application in the text field provided.
    • Existing - use the dropdown menu to select the intended application.
    Note: Each selected repo will be mapped to a new Polaris project within the chosen application.
  6. If you want to assign other repos to a different application, select Add More and repeat steps 4-6 until you have all of the mappings you need.
  7. If you want to assign specific roles to users for these applications, use the Assign Application Role table to specify each role and the users you want to have it. Select Add More to add as many role assignments as you need.
    Important: Verify that each user has access to the relevant repositories in your SCM instance.
  8. (Optional) Configure synchronization settings under Integrations.

    These settings allow you to sync your SCM provider with Polaris and include non-default branches in your onboarding and ongoing synchronization. After onboarding is complete, you can manage these settings at the application level. See Synchronizing Polaris with your SCM Provider.

    1. Select Keep repositories and branches synchronized with SCM to have Polaris actively monitor SCM updates, deletions, renames, and branch modifications and implement the necessary changes to the corresponding Polaris projects and branches.
      Note: If selected without the additional branches option below, this applies only to default branches.
    2. Select Continue to import new repositories for above organizations to automatically create a new project in Polaris when a new repository is added to your SCM.
      Note: This option is only available if you selected the automatic mapping method.
    3. Select Import additional branches matching substrings to import and synchronize non-default branches whose names include specific text.

      After selecting this option, enter a comma-separated list of the text substrings you want to match against (for example, -release, -demo, and so on).

      If you want Polaris to continue monitoring for branch creation events after the initial integration, select Continue to import new branches matching substrings. Polaris will monitor for new branches matching the specified substrings across all selected repositories.

  9. Click Import Repositories.

    On your Portfolio page, a progress bar will track the percentage of completion.

    If the onboarding fails, an email notification will be sent to the user who initiated the onboarding. Organization Admins can monitor activity in audit logs (My Organization > Audit Logs).

    Click Cancel to cancel the import. Any repository in the process of being imported at the time of cancellation will complete in the background after the cancel is accepted, and all further onboarding will be stopped immediately. For example, if you import ten repositories and cancel at 50%, five repositories would be imported and five repositories would not.

Next steps