Module bitbucket

ballerinax/bitbucket Ballerina library

2.0.0
Ballerina Bitbucket connector

Build Trivy GraalVM Check GitHub Last Commit GitHub Issues

Overview

The Bitbucket connector lets Ballerina integrations work with Bitbucket Cloud, Atlassian's Git repository hosting and collaboration service, through version 2.0 of its REST API. It covers the API's full operation surface, including repositories, branches and tags, commits, pull requests, pipelines, snippets, projects, workspaces and permissions, so that source-control and CI/CD workflows can be automated from a Ballerina program.

Key features

  • Create, update and delete repositories, branches, tags and branch restriction rules.
  • Open, review, approve and merge pull requests, and read their activity and comments.
  • Browse commits, diffs, source files and commit statuses.
  • Manage Bitbucket Pipelines, including variables, schedules, runners and caches.
  • Administer workspaces, projects, members and permissions.
  • Share code with snippets and manage SSH and GPG keys.

Setup guide

To use the connector you need a Bitbucket Cloud account and one of the supported credentials.

  1. Sign in to Bitbucket Cloud and open the workspace, project or repository you want to automate.
  2. Create an access token. Open the repository (or workspace) Settings, choose Access tokens and create a token with the scopes your integration needs, such as repository read and write, and pull request read and write.
  3. Copy the token. It is shown only once.
  4. Alternatively, use basic authentication with your Atlassian account email and an API token created under Atlassian account settings > Security > API tokens, or an OAuth 2.0 consumer created under Workspace settings > OAuth consumers.
  5. Keep the credentials in a Config.toml file next to your program and never commit them to source control.

Quickstart

  1. Import the connector.

    Copy
    import ballerinax/bitbucket;
  2. Add the credentials to Config.toml.

    Copy
    accessToken = "<your-access-token>"
  3. Create the client.

    Copy
    configurable string accessToken = ?;
    
    bitbucket:Client bitbucketClient = check new ({auth: {token: accessToken}});
  4. Call an operation, for example fetch the authenticated user, and run the program with bal run.

    Copy
    public function main() returns error? {
        bitbucket:Account _ = check bitbucketClient->getCurrentUser();
    }

Examples

The Bitbucket connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:

Build from the source

Setting up the prerequisites

  1. Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources:

    Note: After installation, remember to set the JAVA_HOME environment variable to the directory where JDK was installed.

  2. Download and install Ballerina Swan Lake.

  3. Download and install Docker.

    Note: Ensure that the Docker daemon is running before executing any tests.

  4. Export Github Personal access token with read package permissions as follows,

    Copy
    export packageUser=<Username>
    export packagePAT=<Personal access token>

Build options

Execute the commands below to build from the source.

  1. To build the package:

    Copy
    ./gradlew clean build
  2. To run the tests:

    Copy
    ./gradlew clean test
  3. To build the without the tests:

    Copy
    ./gradlew clean build -x test
  4. To run tests against different environments:

    Copy
    ./gradlew clean test -Pgroups=<Comma separated groups/test cases>
  5. To debug the package with a remote debugger:

    Copy
    ./gradlew clean build -Pdebug=<port>
  6. To debug with the Ballerina language:

    Copy
    ./gradlew clean build -PbalJavaDebug=<port>
  7. Publish the generated artifacts to the local Ballerina Central repository:

    Copy
    ./gradlew clean build -PpublishToLocalCentral=true
  8. Publish the generated artifacts to the Ballerina Central repository:

    Copy
    ./gradlew clean build -PpublishToCentral=true

Contribute to Ballerina

As an open-source project, Ballerina welcomes contributions from the community.

For more information, go to the contribution guidelines.

Code of conduct

All the contributors are encouraged to read the Ballerina Code of Conduct.

Import

import ballerinax/bitbucket;Copy

Other versions

See more...

Metadata

Released date: about 7 hours ago

Version: 2.0.0

License: Apache-2.0


Security

Direct vulnerabilities: No known direct vulnerabilities

Indirect vulnerabilities: 

Checked on 2026-11-23 via OSV.dev


Compatibility

Platform: any

Ballerina version: 2201.13.0

GraalVM compatible: Yes


Pull count

Total: 40

Current verison: 0


Weekly downloads


Source repository


Keywords

Vendor/Atlassian

Area/Developer Tools

Type/Connector


Contributors