A simple python client for Bitbucket Server
bpc
Bitbucket Python Client is simple python client for Bitbucket Server that uses REST API through Stashy library
bpc
is Python 3 based.
To install dependencies just launch:
pip install -r src/requirements.txt
Or install them manually
pip install stashy
pip install gitpython
pip install click
Note: it is take for granted that your default Python installation is Python 3 if not just explicitly run bpc
with Python 3: python3 bpc
bpc
needs configuration for at least one Bitbucket server; to add new server configuration invoke command
bpc config
and provide required details:
bpc
bpc
just use a personal access tokenNon interactive way:
bpc config --server-base-url "https://www.example.com/mybitbucketinstance" --server-shortcut mybitbucketinstance --username myuser --token mytoken
The first server added to bpc will be used as default one; to change it invoke:
bpc config --set-default-server mybitbucketinstance
Note: default server is used only when querying for Bitbucket projects/repositories; the server configuration for managing Pull Request will be guess from local git repository
To manage Pull Requests bpc
shall be invoked in folder containing a git repository
Invoke command:
bpc pr
and provide required details:
Non interactive way:
bpc pr --title "PR title" --description "PR description"
bpc pr --set-default-branch myBranch
bpc config --pr-set-repo-title [true|false]
To enabled disable request for PR description, use the following command:
bpc config --pr-set-empty-description [true|false]
bpc config --pr-set-auto-fetch [true|false]
To enable/disable pushing changes to remote server before opening PR, use the following command:
bpc config --pr-set-auto-push [true|false]
bpc config --set-default-pr-reviewers=userA,userB --project=projectName --server=serverShortcut
To list all the PR pending for a repository, just invoke command:
bpc pr --list
List all the projects in default Bitbucket server (projects that the current user has access to):
bpc remote
Add flag --server
to specify the server that will be queried
List all repositories on a specific Bitbucket project:
bpc remote --project PROJECT_NAME
bcp is using Click library to edit information, to change default editor in Linux you can edit file ~/.selected_editor
~/.bpc/config.json
to spot for features not yet officially releasedYou can retrieve some debug configurations is .vscode/.launch.json
pipreqs
pip install pipreqs
pipreqs
to get requirements.txt listpip install pyinstaller
pyinstaller.exe src/bpc.spec
lab for gitlab has given me the idea to implement this client, but is very far to have comparable features