Table of contents

Plugin management


CloudBees Bitbucket Branch Source Plugin

Important

On April 29th, 2019, Atlassian updated their suite APIs for both Bitbucket and JIRA to comply with GDPR privacy requirements. Cloudbees has evaluated this change against the CloudBees BitBucket Branch Source Plugin and the CloudBees JIRA Plugin.

  1. BitBucket Cloud Pipeline jobs created with "classic" Jenkins are unaffected.

  2. There is a limited impact to Bitbucket Cloud Pipeline jobs created using Blue Ocean:

    1. If you are running Blue Ocean version 1.15.1 or earlier, you will be unable to create or edit BitBucket Cloud Pipeline jobs.

    2. Upgrading to Blue Ocean 1.16.0 or later fixes this issue.

    3. However, because "owner name" has been removed from the BitBucket REST API, when you edit Bitbucket Cloud Pipelines in the "classic" Jenkins UI, a UUID (instead of human-readable text) is displayed in the "owner" field of the Pipeline.

We do not anticipate any broader customer impact. If you encounter a change in behavior that you believe is due to the BitBucket or JIRA API changes, please contact CloudBees Support for assistance.

Introduction

CloudBees Bitbucket Branch Source Plugin (Bitbucket Plugin up now) allows use of Bitbucket Cloud and Server as a multi-branch project source in two different ways:

  • Single repository source: automatic creation of jobs for branches and pull requests in a specific repository.

  • Team/Project folders: automatic creation of multi-branch projects for each visible repository in a specific Bitbucket Team or Project.

    IMPORTANT: This plugin is not compatible with versions of Bitbucket Server previous to 4.0.

Branches and pull requests auto-discovering

This plugin adds an additional item in the "Branch Sources" list of multi-branch projects. Once configured, branches and pull requests are automatically created and built as branches in the multi-branch project.

Follow these steps to create a multi-branch project with Bitbucket as a source:

  1. Create the multi-branch project. This step depends on which multi-branch plugin is installed. For example, "Multibranch Pipeline" should be available as project type if Pipeline Multibranch plugin is installed.

    screenshot 1
  2. Select "Bitbucket" as Branch Source

    screenshot 2
  3. Set credentials to access Bitbucket API and checkout sources (see "Credentials configuration" section below).

  4. Set the repository owner and name that will be monitored for branches and pull requests.

  5. If using Bitbucket Server the server base URL needs to be configured (expand the Advanced section to do it).

    screenshot 4
  6. Finally, save the project. The initial indexing process will run and create projects for branches and pull requests.

    screenshot 5

Team Folders

Bitbucket Team/Project Folders project type can be used to automatically track branches and pull requests in all repositories in a Bitbucket Team or Project.

  1. Create a project of type Bitbucket Team/Project. The project name will be proposed automatically as default Owner (or Team) name.

    screenshot 6
  2. Configure the repository owner (if the proposed value does not match with the actual team or username). It could be:

    1. A Bitbucket Cloud Team name: all repositories in the team are imported as Multibranch projects.

    2. A Bitbucket Server Project ID: all repositories in the project are imported as Multibranch projects. Note that the project ID needs to be used instead of the project name.

    3. A regular username: all repositories which the username is owner of are imported.

      screenshot 8
  3. Save the configuration and an initial indexing process starts, once it finishes a Multibranch project is created for each repository.

    screenshot 9

Webhooks registering

The use of Bitbucket webhooks allows to trigger builds on branches and pull requests just when a new commit is done. Bitbucket plugin expose a special service to listen to this webhook requests and acts accordingly by triggering a new reindex and finally triggering builds on matching branches or pull requests.

For both Bitbucket Multibranch projects and Bitbucket Team projects there is an option in the configuration page to let Jenkins to automatically register the webhooks in all involved repositories.

Important
This feature is only available for Bitbucket Cloud at the moment.
screenshot 4
Important
In order to have the auto-registering process working fine the Jenkins base URL must be properly configured in Manage Jenkins » Configure System

Credentials configuration

The configuration of Bitbucket Plugin (for both Bitbucket Multibranch projects and Bitbucket Team/Project) has two credentials to configure:

  1. Scan Credentials: credentials used to access Bitbucket API in order to discover repositories, branches and pull requests. If not set then anonymous access is used, so only public repositories, branches and pull requests are discovered and managed. Note that the Webhooks auto-register feature requires scan credentials to be set. Only HTTP credentials are accepted in this field.

  2. Checkout Credentials: credentials used to checkout sources once the repository, branch or pull request is discovered. HTTP and SSH credentials are allowed. If not set then Scan Credentials are used.

screenshot 3