BitBucket module
================

Complete API reference
----------------------

The workflow sections below cover common operations. The source-backed
references list every public method and current signature for the compatible,
Cloud OO, and Server/Data Center clients.

.. autoclass:: atlassian.bitbucket.Bitbucket
   :members:
   :undoc-members:

.. autoclass:: atlassian.bitbucket.cloud.Cloud
   :members:
   :undoc-members:

.. autoclass:: atlassian.bitbucket.server.Server
   :members:
   :undoc-members:

Server/Data Center pagination
-----------------------------

Several Server/Data Center methods return Python generators, including
``project_list()``, ``repo_list()``, ``repo_all_list()``, and
``get_pull_requests()``. Iterate them to process every page lazily, or wrap
them in ``list`` only when the entire result is small enough to hold in memory.
Generators do not have a ``.json()`` method because each yielded value is
already a Python dictionary.

.. code-block:: python

    for repository in bitbucket.repo_all_list("PROJ"):
        for pull_request in bitbucket.get_pull_requests("PROJ", repository["slug"], state="OPEN"):
            print(pull_request["title"])

``advanced_mode=True`` is for callers that need raw ``requests.Response``
objects from individual requests. Do not enable it for the high-level paginated
methods above; use their yielded dictionaries instead.

Personal repositories (Server/Data Center)
------------------------------------------

Repository methods accept a personal-project user slug in place of a project
key. Prefix the Bitbucket username with ``~`` and the legacy client uses the
user-centric ``/users/{userSlug}/repos/{repositorySlug}`` endpoint. This works
for pull-request settings and every other repository method that accepts
``project_key`` and ``repository_slug``.

.. code-block:: python

    owner = "~alice"
    settings = bitbucket.get_pull_request_settings(owner, "personal-repository")
    bitbucket.set_pull_request_settings(owner, "personal-repository", settings)

For the object-oriented Server/Data Center client, use
``personal_repositories()``. It accepts either ``"alice"`` or ``"~alice"``.

.. code-block:: python

    from atlassian.bitbucket.server import Server

    bitbucket = Server("https://bitbucket.example.com", username="admin", password="token")
    repository = bitbucket.personal_repositories("alice").get("personal-repository")
    print(repository.name)

Hook scripts (Data Center 8+)
-----------------------------

Hook scripts are a Bitbucket Data Center feature, not Bitbucket Cloud. A system
administrator first registers the global script, then a project or repository
administrator configures the script for its target scope. Bitbucket Data Center
8.18 and newer disable this feature by default; enable
``feature.hook.scripts=true`` in ``bitbucket.properties`` and restart the
cluster before use.

.. code-block:: python

    with open("hooks/audit-pushes.sh", "rb") as script_file:
        hook_script = bitbucket.create_hook_script(
            script_file.read(),
            name="Audit pushes",
            hook_type="POST",  # or "PRE"
            description="Records every push",
        )

    bitbucket.configure_project_hook_script(
        "PROJ", hook_script["id"], trigger_ids=["repo:refs_changed"]
    )
    bitbucket.configure_repo_hook_script(
        "PROJ", "repository", hook_script["id"], trigger_ids=["repo:refs_changed"]
    )

``get_project_hook_scripts()`` and ``get_repo_hook_scripts()`` yield all
configured scripts. ``delete_project_hook_script()`` and
``delete_repo_hook_script()`` remove only a scope configuration; they do not
delete the global registered script.

The global registered script itself is managed with the server-level methods.
``get_hook_script()`` returns a script's metadata, ``get_hook_script_content()``
returns its raw body, ``update_hook_script()`` replaces its body or metadata,
and ``delete_hook_script()`` removes it entirely:

.. code-block:: python

    metadata = bitbucket.get_hook_script(hook_script["id"])
    script = bitbucket.get_hook_script_content(hook_script["id"])

    bitbucket.update_hook_script(
        hook_script["id"],
        content=script.replace(b"old", b"new"),
        name="Audit pushes (v2)",
        hook_type="POST",
        description="Records every push",
    )
    bitbucket.delete_hook_script(hook_script["id"])

Release report from two refs (Server/Data Center)
-------------------------------------------------

To report merged pull requests between two release tags or commit hashes, first
iterate ``get_changelog()`` and then resolve the pull requests associated with
each returned commit. A pull request can be associated with multiple commits,
so retain the results by pull request ID to avoid duplicates.

.. code-block:: python

    merged_pull_requests = {}
    for commit in bitbucket.get_changelog("PROJ", "repository", "refs/tags/v1.0", "refs/tags/v1.1"):
        for pull_request in bitbucket.get_pull_requests_contain_commit("PROJ", "repository", commit["id"]):
            if pull_request["state"] == "MERGED":
                merged_pull_requests[pull_request["id"]] = pull_request

    for pull_request in merged_pull_requests.values():
        print(pull_request["title"])

See ``examples/bitbucket/bitbucket_server_release_report.py`` for a complete
environment-variable-based script.

Commits belonging to an open pull request may not be reachable from the
repository ref used by ``get_commits``. To retrieve the commits that belong to
a specific pull request on Server/Data Center, query the pull-request commits
endpoint instead:

.. code-block:: python

    for commit in bitbucket.get_pull_requests_commits("PROJ", "repository", pull_request_id):
        print(commit["id"])

The Cloud object model provides the equivalent operation as
``repository.pullrequests.get(pull_request_id).commits``. Use
``get_pull_requests_contain_commit`` when starting from an individual commit
and looking up its associated pull requests.

Manage projects
---------------

.. code-block:: python

    # Project list
    bitbucket.project_list()

    # Repo list
    bitbucket.repo_list(project_key)

    # Project info
    bitbucket.project(key)

    # Create project
    bitbucket.create_project(key, name, description="My pretty project")

    # Get users who has permission in project
    bitbucket.project_users(key, limit=99999, filter_str=None)

    # Get project administrators for project
    bitbucket.project_users_with_administrator_permissions(key)

    # Get Project Groups
    bitbucket.project_groups(key, limit=99999, filter_str=None)

    # Get groups with admin permissions
    bitbucket.project_groups_with_administrator_permissions(key)

    # Project summary
    bitbucket.project_summary(key)

    # Check default permission for project
    bitbucket.project_default_permissions(project_key, permission)

    # Grant default permission for project
    bitbucket.project_grant_default_permissions(project_key, permission)

    # Grant project permission to a specific user
    bitbucket.project_grant_user_permissions(project_key, username, permission)

    # Grant project permission to a specific group
    bitbucket.project_grant_group_permissions(project_key, group_name, permission)

    # Remove default permission for project
    bitbucket.project_remove_default_permissions(project_key, permission)

    # Remove all project permissions for a specific user
    bitbucket.project_remove_user_permissions(project_key, username)

    # Remove all project permissions for a specific group
    bitbucket.project_remove_group_permissions(project_key, groupname)

Manage repositories
-------------------

.. code-block:: python

    # Get single repository
    bitbucket.get_repo(project_key, repository_slug)

    # Update single repository
    bitbucket.update_repo(project_key, repository_slug, description="Repo description")

    # Get labels for a single repository
    bitbucket.get_repo_labels(project_key, repository_slug)

    # Set label for a single repository
    bitbucket.set_repo_label(project_key, repository_slug, label_name)

    # Disable branching model
    bitbucket.disable_branching_model(project_key, repo_key)

    # Enable branching model
    bitbucket.enable_branching_model(project_key, repo_key)

    # Get branching model
    bitbucket.get_branching_model(project_key, repo_key)

    # Set branching model
    data = {'development': {'refId': None, 'useDefault': True},
            'types': [{'displayName': 'Bugfix',
                       'enabled': True,
                       'id': 'BUGFIX',
                       'prefix': 'bugfix-'},
                      {'displayName': 'Feature',
                       'enabled': True,
                       'id': 'FEATURE',
                       'prefix': 'feature-'},
                      {'displayName': 'Hotfix',
                       'enabled': True,
                       'id': 'HOTFIX',
                       'prefix': 'hotfix-'},
                      {'displayName': 'Release',
                       'enabled': True,
                       'id': 'RELEASE',
                       'prefix': 'release/'}]}
    bitbucket.set_branching_model(project_key, repo_key, data)

    bitbucket.repo_users(project_key, repo_key, limit=99999, filter_str=None)

    bitbucket.repo_groups(project_key, repo_key, limit=99999, filter_str=None)

    # Grant repository permission to an specific user
    bitbucket.repo_grant_user_permissions(project_key, repo_key, username, permission)

    # Grant repository permission to an specific group
    bitbucket.repo_grant_group_permissions(project_key, repo_key, groupname, permission)

    # Delete a repository (DANGER!)
    bitbucket.delete_repo(project_key, repository_slug)

    # Fork repo inside same project
    fork_repository(project_key, repository_slug, new_repository_slug)

    # Fork repo to new project
    fork_repository_new_project(project_key, repository_slug, new_project_key, new_repository_slug)

Manage Code Insights
--------------------

.. code-block:: python

    # Delete an existing Code Insights report
    bitbucket.delete_code_insights_report(project_key, repository_slug, commit_hash, report_key)

    # Create a new Code Insights report
    report = {
        'details': 'This is an example report',
        'result': 'FAIL',
        'reporter': 'Anonymous',
        'link': 'http://some-url',
        'logo-url': 'http://some-url',
        'data': [
            {
                'title': 'Example coverage',
                'type': 'PERCENTAGE',
                'value': 85
            }
        ]
    }
    bitbucket.create_code_insights_report(project_key, repository_slug, commit_hash, report_key, 'Code Insights Report', **report)

    # Add annotations to a Code Insights report
    annotations = [
        {
        'path': 'some/path/to/file',
        'line': 32,
        'message': 'Roses are red, Violets are blue, Unexpected { on line 32',
        'severity': 'MEDIUM'
        }
    ]
    bitbucket.add_code_insights_annotations_to_report(project_key, repository_slug, commit_hash, report_key, **annotations)

Groups and admins
-----------------

.. code-block:: python

    # Get groups. Use 'group_filter' parameter to get specific groups.
    bitbucket.groups(group_filter="group", limit=99999)

    # Get group of members
    bitbucket.group_members(group, limit=99999)

    # All project administrators
    bitbucket.all_project_administrators()

    # Get users. Use 'user_filter' parameter to get specific users.
    bitbucket.get_users(user_filter="username", limit=25, start=0)

Manage code
-----------

.. code-block:: python

    # Get repositories list from project
    bitbucket.repo_list(project_key, limit=25)

    # Create a new repository.
    # Requires an existing project in which this repository will be created. The only parameters which will be used
    # are name and scmId.
    # The authenticated user must have PROJECT_ADMIN permission for the context project to call this resource.
    bitbucket.create_repo(project_key, repository, forkable=False, is_private=True)

    # Bitbucket Server/Data Center: inspect or change whether a repository
    # accepts forks. These calls require repository administration permission.
    is_forkable = bitbucket.get_repo_forkable(project_key, repository)
    bitbucket.set_repo_forkable(project_key, repository, forkable=True)
    bitbucket.enable_repo_forking(project_key, repository)
    bitbucket.disable_repo_forking(project_key, repository)

    # Get branches from repo
    bitbucket.get_branches(project, repository, filter='', limit=99999, details=True, boost_matches=False)

    # Creates a branch using the information provided in the request.
    # The authenticated user must have REPO_WRITE permission for the context repository to call this resource.
    bitbucket.create_branch(project_key, repository, name, start_point, message)

    # Delete branch from related repo
    bitbucket.delete_branch(project, repository, name, end_point=None)

    # Get pull requests
    bitbucket.get_pull_requests(project, repository, state='OPEN', order='newest', limit=100, start=0)

    # Get pull request activities
    bitbucket.get_pull_requests_activities(project, repository, pull_request_id)

    # Get pull request changes
    bitbucket.get_pull_requests_changes(project, repository, pull_request_id)

    # Get pull request commits
    bitbucket.get_pull_requests_commits(project, repository, pull_request_id)

    # Add comment into pull request
    bitbucket.add_pull_request_comment(project, repository, pull_request_id, text)

    # Reply to a comment of a pull request
    bitbucket.add_pull_request_comment(project, repository, pull_request_id, text, parent_id=None)

    # Get required reviewers for PR creation
    bitbucket.get_required_reviewers_for_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, dest_branch)

    # Create a new pull request between two branches.
    bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description)

    # Create a new pull request between two branches with one reviewer
    bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, reviewers='name')

    # Create a new pull request between two branches with multiple reviewers.
    bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, reviewers=['name1', 'name2'])

    # Create a new pull request between two branches with required reviewers.
    bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, include_required_reviewers=True)

    # Delete a pull request
    bitbucket.delete_pull_request(project, repository, pull_request_id, pull_request_version)

    # Get tags for related repo
    bitbucket.get_tags(project, repository, filter='', limit=99999)

    # Get project tags
    # The authenticated user must have REPO_READ permission for the context repository to call this resource
    bitbucket.get_project_tags(project, repository, tag_name)

    # Set tag
    # The authenticated user must have REPO_WRITE permission for the context repository to call this resource
    bitbucket.set_tag(project, repository, tag_name, commit_revision, description=None)

    # Delete tag
    # The authenticated user must have REPO_WRITE permission for the context repository to call this resource
    bitbucket.delete_tag(project, repository, tag_name)

    # Get diff
    bitbucket.get_diff(project, repository, path, hash_oldest, hash_newest)

    # Get commit list from repo
    bitbucket.get_commits(project, repository, hash_oldest, hash_newest, limit=99999)

    # Get change log between 2 refs
    bitbucket.get_changelog(project, repository, ref_from, ref_to, limit=99999)

    # Get raw content of the file from repo
    bitbucket.get_content_of_file(project, repository, filename, at=None, markup=None)
    """
        Retrieve the raw content for a file path at a specified revision.
        The authenticated user must have REPO_READ permission for the specified repository to call this resource.
    """

Branch permissions
------------------

.. code-block:: python

    # Set branches permissions
    bitbucket.set_branches_permissions(project_key, multiple_permissions=False, matcher_type=None, matcher_value=None, permission_type=None, repository_slug=None, except_users=[], except_groups=[], except_access_keys=[], start=0, limit=25)

    # Delete a single branch permission by permission id
    bitbucket.delete_branch_permission(project_key, permission_id, repository_slug=None)

    # Get a single branch permission by permission id
    bitbucket.get_branch_permission(project_key, permission_id, repository_slug=None)

Pull Request management
-----------------------

.. code-block:: python

    # Decline pull request
    bitbucket.decline_pull_request(project_key, repository, pr_id, pr_version)

    # Check if pull request can be merged
    bitbucket.is_pull_request_can_be_merged(project_key, repository, pr_id)

    # Merge pull request
    bitbucket.merge_pull_request(project_key, repository, pr_id, pr_version)

    # Reopen pull request
    bitbucket.reopen_pull_request(project_key, repository, pr_id, pr_version)

    # Assign user as a reviewer of pull request
    bitbucket.assign_pull_request_participant_role(project_key, repository, pr_id, "REVIEWER", username)

    # Add a blocker comment to a pull request (create a new task)
    bitbucket.add_pull_request_blocker_comment(project_key, repository, pr_id, "Input task text here", "BLOCKER")

    # Get blocker comments for a pull request
    bitbucket.search_pull_request_blocker_comment(project_key, repository, pr_id)

Conditions-Reviewers management
-------------------------------

.. code-block:: python

    # Get all project conditions with reviewers list for specific project
    bitbucket.get_project_conditions(project_key)

    # Get a project condition with reviewers list for specific project
    bitbucket.get_project_condition(project_key, id_condition)

    # Create project condition with reviewers for specific project
    # :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
    bitbucket.create_project_condition(project_key, condition)

    # Update a project condition with reviewers for specific project
    # :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
    bitbucket.update_project_condition(project_key, condition, id_condition)

    # Delete a project condition for specific project
    bitbucket.delete_project_condition(project_key, id_condition)

    # Get all repository conditions with reviewers list for specific repository in project
    bitbucket.get_repo_conditions(project_key, repo_key)

    # Get repository conditions with reviewers list only only conditions type PROJECT for specific repository in project
    bitbucket.get_repo_project_conditions(project_key, repo_key)

    # Get repository conditions with reviewers list only conditions type REPOSITORY for specific repository in project
    bitbucket.get_repo_repo_conditions(project_key, repo_key)

    # Get a project condition with reviewers list for specific repository in project
    bitbucket.get_repo_condition(project_key, repo_key, id_condition)

    # Create project condition with reviewers for specific repository in project
    # :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
    bitbucket.create_repo_condition(project_key, repo_key, condition)

    # Update a project condition with reviewers for specific repository in project
    # :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
    bitbucket.update_repo_condition(project_key, repo_key, condition, id_condition)

    # Delete a project condition for specific repository in project
    bitbucket.delete_repo_condition(project_key, repo_key, id_condition)

For Bitbucket Server/Data Center, administrators can inspect cluster node
information with the legacy client:

.. code-block:: python

    from atlassian import Bitbucket

    bitbucket = Bitbucket(
        url="https://bitbucket.example.com",
        username="admin",
        password="password",
    )
    cluster = bitbucket.get_cluster_info()

Bitbucket Cloud
---------------

Bitbucket Cloud and Bitbucket Server/Data Center have different REST API
models. Use :class:`atlassian.bitbucket.cloud.Cloud` for Cloud: it starts from
``workspaces`` and then navigates to repositories. Use ``Bitbucket`` or
:class:`atlassian.bitbucket.server.Server` for Server/Data Center project
endpoints. Do not pass a Cloud URL to the legacy Server/Data Center methods.

Use an Atlassian account email and a scoped Bitbucket API token with the
required repository and workspace permissions. The client uses HTTP Basic
authentication automatically. App passwords were retired by Bitbucket Cloud in
July 2026, so new integrations must use API tokens.

.. code-block:: python

    import os

    from atlassian.bitbucket import Cloud

    cloud = Cloud(
        username=os.environ["ATLASSIAN_EMAIL"],
        password=os.environ["BITBUCKET_API_TOKEN"],
    )

    # /2.0/user/workspaces is the supported listing route. ``each()`` resolves
    # each entry and yields full workspace objects.
    for workspace in cloud.workspaces.each():
        print(workspace.slug)

    # Restrict the list to workspaces administered by the authenticated user.
    admin_workspaces = list(cloud.workspaces.each(administrator=True))

    repository = cloud.workspaces.get("workspace-slug").repositories.get("repository-slug")
    print(repository.name)

.. code-block:: python

    # Get a list of workspaces.
    cloud.workspaces.each()

    # Get a single workspace by workspace slug.
    workspace = cloud.workspaces.get(workspace_slug)

    # Get a list of permissions in a workspace (this may not work depending on the size of your workspace)
    workspace.permissions.each()

    # Get a list of repository permissions in a workspace (this may not work depending on the size of your workspace)
    workspace.permissions.repositories()

    # Get a single repository permissions in a workspace
    workspace.permissions.repositories(repo_slug)

    # Get a list of projects in a workspace
    workspace.projects.each()

    # Get a single project from a workspace by project key
    project = workspace.projects.get(project_key)

    # Get a list of repos from a project
    project.repositories.each()

    # Get a repository
    repository = workspace.repositories.get(repository_slug)

    # Commit history supports include/exclude refs and a file-path filter.
    commits = repository.commits.each(
        include="main",
        exclude="release",
        path="src/app.py",
    )
    for commit in commits:
        print(commit.hash)

The Cloud commits endpoint does not support arbitrary ``q`` expressions for
filtering by author or date. Filter those fields in the returned commits, or
use ``include``, ``exclude`` and ``path`` when those server-side filters fit
the use case.

.. code-block:: python

    # Read raw bytes from a file at a branch, tag, or commit SHA
    readme = repository.get_source_file("main", "README.md")

    # List directory entries at a branch, tag, or commit SHA
    source_entries = repository.get_source_directory("main", "src")["values"]

    # Get a list of deployment environments from a repository
    repository.deployment_environments.each()

    # Get a deployment environment by key
    deployment_environment = repository.deployment_environments.get(deployment_environment_key)

    # Get deployment environment variables from an environment
    deployment_environment_variables = deployment_environment.deployment_environment_variables.each()

    # Create a non-secured deployment environment variable.
    new_deployment_environment_variable = deployment_environment.deployment_environment_variables.create(
    "KEY", "VALUE", False
    )

    # Update the 'key' field of repository_variable
    updated_deployment_environment_variable = new_deployment_environment_variable.update(
    key="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_KEY"
    )

    # Update the 'value' field of repository_variable
    updated_deployment_environment_variable = new_deployment_environment_variable.update(
    value="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_VALUE"
    )

    # Delete deployment environment variable
    updated_deployment_environment_variable.delete()

    # Get a list of group permissions from a repository
    repository.group_permissions.each()

    # Get a single group permission from a repository by group slug
    repository.group_permissions.get(group_slug)

    # Get a list of repository variables from a repository
    repository.repository_variables.each()

    # Get a repository variable by key
    repository_variable = repository.repository_variables.get(
    repository_variable_key
    )

    # Create a non-secured repository variable.
    new_repository_variable = repository.repository_variables.create(
    "KEY", "VALUE", False
    )

    # Update the 'key' field of repository_variable
    updated_repository_variable = repository_variable.update(
    key="UPDATED_REPOSITORY_VARIABLE_KEY"
    )

    # Update the 'value' field of repository_variable
    updated_repository_variable = repository_variable.update(
    value="UPDATED_REPOSITORY_VARIABLE_VALUE"
    )

    # Delete repository_variable
    repository_variable.delete()

    # Look up a repository pipeline variable by its name; the returned object
    # exposes its UUID and can be updated without constructing a URL manually.
    repository_variable = repository.repository_variables.get_by_key("qww")
    if repository_variable is not None:
        print(repository_variable.uuid)
        repository.repository_variables.update_by_key(
            "qww",
            "new-value",
            secured=True,
        )

    # Get a list of hooks from a repository
    repository.hooks.each()

    # Create a hook for a repository
    hook = repo.hooks.create(
    url="endpoint-url", description="description", active=True,
    events=["a-repository-event"]
    )

    # Get a single hook for a repository
    hook = repo.hooks.get("a-webhook-id")

    # Update a specific hook for a repository
    hook.update(
    url="endpoint-url", description="description", active=True,
    events=["a-repository-event"]
    )

    # Delete a speicifc hook for a repository
    hook.delete()

    # Get a list of workspace members
    workspace.members.each()

    # Get a specific workspace member
    workspace.members.get("a-user-account-id")
    workspace.members.get("{a-user-uuid}")

Pipelines management
--------------------

.. code-block:: python

    # Object oriented:
        # Get the repository first
        r = cloud.workspaces.get(workspace).repositories.get(repository)

        # Get first ten Pipelines results for repository
        r.pipelines.each()

        # Get Pipelines results for repository, newest first
        r.pipelines.each(sort="-created_on")

        # Trigger default Pipeline on the latest revision of the master branch
        r.pipelines.trigger()

        # Trigger default Pipeline on the latest revision of the develop branch
        r.pipelines.trigger(branch="develop")

        # Trigger default Pipeline on a specific revision of the develop branch
        r.pipelines.trigger(branch="develop", commit="<40-char hash>")

        # Trigger specific Pipeline on a specific revision of the master branch
        r.pipelines.trigger(commit="<40-char hash>", pattern="style-check")

        # Trigger specific Pipeline of the master branch with specific variables
        r.pipelines.trigger(pattern="style-check", variables=[{ "key": "var-name", "value": "var-value" }])

        # Get specific Pipeline by UUID
        pl = r.pipelines.get("{7d6c327d-6336-4721-bfeb-c24caf25045c}")

        # Stop specific Pipeline by UUID
        pl.stop()

        # Get steps of Pipeline specified by UUID
        pl.steps()

        # Get step of Pipeline specified by UUIDs
        s = pl.step("{56d2d8af-6526-4813-a22c-733ec6ecabf3}")

        # Get log of step of Pipeline specified by UUIDs
        s.log()

    # or function oriented:
        # Get most recent Pipelines results for repository
        bitbucket.get_pipelines(workspace, repository)

        # Trigger default Pipeline on the latest revision of the master branch
        bitbucket.trigger_pipeline(workspace, repository)

        # Trigger default Pipeline on the latest revision of the develop branch
        bitbucket.trigger_pipeline(workspace, repository, branch="develop")

        # Trigger default Pipeline on a specific revision of the develop branch
        bitbucket.trigger_pipeline(workspace, repository, branch="develop", revision="<40-char hash>")

        # Trigger specific Pipeline on a specific revision of the master branch
        bitbucket.trigger_pipeline(workspace, repository, revision="<40-char hash>", name="style-check")

        # Get specific Pipeline by UUID
        bitbucket.get_pipeline(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}")

        # Stop specific Pipeline by UUID
        bitbucket.stop_pipeline(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}")

        # Get steps of Pipeline specified by UUID
        bitbucket.get_pipeline_steps(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}")

        # Get step of Pipeline specified by UUIDs
        bitbucket.get_pipeline_step(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}", "{56d2d8af-6526-4813-a22c-733ec6ecabf3}")

        # Get log of step of Pipeline specified by UUIDs
        bitbucket.get_pipeline_step_log(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}", "{56d2d8af-6526-4813-a22c-733ec6ecabf3}")

Manage issues
-------------

.. code-block:: python

    # Object oriented:
        # Get the repository first
        r = cloud.workspaces.get(workspace).repositories.get(repository)

        # Get all tracked issues
        r.issues.each()

        # Get all unassigned issues and sort them by priority
        r.issues.get(sort_by="priority", query='assignee = null')

        # Create a new issue of kind 'enhancement' and priority 'minor'
        r.issues.create("New idea", "How about this", kind="enhancement", priority="minor")

        # Update the 'priority' field of the issue 42
        r.issues.get(42).priority = "blocker"

        # Mark issue 42 as resolved
        r.issues.get(42).state = "resolved"

        # Get information about issue 1
        i = r.issues.get(1)

        # Delete issue 123
        r.issues.get(123).delete()

    # or function oriented:
        # Get all tracked issues
        bitbucket.get_issues(workspace, repository)

        # Get all unassigned issues and sort them by priority
        bitbucket.get_issues(workspace, repository, sort_by="priority", query='assignee = null')

        # Create a new issue
        bitbucket.create_issue(workspace, repository, "The title", "The description")

        # Create a new issue of kind 'enhancement' and priority 'minor'
        bitbucket.create_issue(workspace, repository, "New idea", "How about this", kind="enhancement", priority="minor")

        # Update the 'priority' field of the issue 42
        bitbucket.update_issue(workspace, repository, 42, priority="blocker")

        # Mark issue 42 as resolved
        bitbucket.update_issue(workspace, repository, 42, state="resolved")

        # Get information about issue 1
        bitbucket.get_issue(workspace, repository, 1)

        # Delete issue 123
        bitbucket.delete_issue(workspace, repository, 123)
