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:
- server-base-url: Bitbucket server web url e.g. "https://www.example.com/mybitbucketinstance"
- this is not the git repository url, that is like https://www.example.com/mybitbucketinstance/scm
- server-shortcut: mnemonic name to ease server management in
bpc
- usarname: user name to access Bitbucket server
- token: do not store plain password in
bpc
just use a personal access token- please refer to upstream support page
Non 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"
-
A default target branch can be specified for each needed repository, invoke command:
bpc pr --set-default-branch myBranch
-
Repository name can be added to PR title: it can be enable disabled:
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]
-
To enable/disable fetch changes before opening PR, use the following command:
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]
-
To specify Pull Request custom reviewers (per project), use the command:
bpc config --set-default-pr-reviewers=userA,userB --project=projectName --server=serverShortcut
- Note: Bitbucket username are case sensitive
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
- Some command line options can be shortened when the resulting command is unambigous
- At your own risk, you can dig in
~/.bpc/config.json
to spot for features not yet officially released
- Pretty print servers list
- Select editor from bpc
- Clone repositories directly from bpc
You can retrieve some debug configurations is .vscode/.launch.json
- Install
pipreqs
pip install pipreqs
- just launch
pipreqs
to get requirements.txt list
- Install pyinstaller
pip install pyinstaller
- Launch comand
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