Skip to content

Python module for interacting with Bitbucket Cloud's API

License

Notifications You must be signed in to change notification settings

sarvin/bitbucketpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitbucketpy

WIP Python package for interacting with Bitbucket Cloud's API.

Usage

You'll need three items:

  • EMAIL: The email address used to interact with Bitbucket.
  • PASSWORD: An API key used to authenticate with Bitbucket.
  • API_ENDPOINT: ex https://api.bitbucket.org/2.0

Interact with the repository API

import bitbucket
api = bitbucket.API(WORKSPACE, EMAIL, PASSWORD)
repository = api.get_repository(REPOSITORY_NAME)

Get branches in repository

branches = repository.branches()
for branch in branches:
    print(branch.name)

The latest commit on a branch

commit = next(branch.commits)

Find commits ahead of master

feature_branch = repository.branch('feature_branch_name')

commits = [
    commit
    for commit in feature_branch.commits({'exclude': 'master', 'pagelen': 100})
]

print(f"feature_branch_name is {len(commits)} commits ahead of master")

Find a tag in the repository

tag = repository.tag('1.0.0')

Find pipelines for a branch

pipelines = list(api.get_pipelines(
    'REPO_SLUG',
    {
        'target.branch':'BRANCH_NAME',
        'sort': '-created_on',
        'pagelen':20}))

About

Python module for interacting with Bitbucket Cloud's API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages