Work seamlessly with Bitbucket from the command line
Notice: This repository is no longer actively maintained. Atlassian has announced that support for Bitbucket Server, would end on Feb. 15, 2024. You can learn more about this here.
This tool is designed to work with Bitbucket Server Edition (Enterprise) and not with Bitbucket Cloud / bitbucket.org
The API Endpoints and the way the tool interacts with the server is different from the cloud version, hence this tool will break if used with the cloud version.
From Source
git clone https://github.com/psadi/bbcli.git
cd bbcli
pip3 install build
python3 -m build .
pip3 install --user dist/bb-<version>.tar.gz
From Releases
Download the latest build from releases page
pip3 install --user bb-<version>.tar.gz
From Docker
A docker image is published to hub.docker.com
docker pull psadi/bbcli:<tag>
docker run -it --rm -v $HOME/.config/bb:$HOME/.config/bb -v $(pwd):/app/. --network host psadi/bbcli [OPTIONS] COMMAND [ARGS]
Example:
docker run -it --rm -v $HOME/.config/bb:$HOME/.config/bb -v $(pwd):/app/. --network host psadi/bbcli pr create --target master
- Run the following command to perform initial setup, this will setup a
config.ini
under$XDG_CONFIG_HOME/bb
respective to the OS, make sure to remove the '/` at the end of your bitbucket_host:
bb auth setup
- Validate
-
Check the config file status
bb auth status
-
If the config file is setup properly, run
bb auth test
to validate -
if all went well, you should get a response like this
> bb auth test
⠏ Validating connection with 'https://bitbucket.<company>.com'... OK
Create pull request
Command | Action |
---|---|
bb pr create --target master |
creates pull request and asks for confirmation |
bb pr create --target master --yes |
creates pull request without prompt |
Show diff of files (ADD/DELETE/MODIFY & RENAME) as an overview
Command | Action |
---|---|
bb pr create --target master --yes --diff |
creates pull request without prompt and shows diff from the PR raised |
bb pr delete --id 1 --yes --diff |
deletes pull request without prompt and shows diff befoew PR is deleted |
bb pr diff --id 1 |
shows diff for the given pull request id |
Delete pull request(s)
Command | Action |
---|---|
bb pr delete --id 1 |
deletes the given pull request number with confirmation prompt |
bb pr delete --id 1 --yes |
deletes the given pull request number without prompt |
bb pr delete --id 1,2,3 |
deletes multiple pull requests |
Show pull request(s) authored/reviewer
Command | Action |
---|---|
bb pr list |
show pull requests in current repository [Default] |
bb pr list --author |
show pull requests authored in current repository |
bb pr list --author --all |
show pull requests authored in all repositories |
bb pr list --reviewer |
show pull requests that you are a reviewer in current repository |
bb pr list --reviewer --all |
show pull requests that you are a reviewer in all repositories |
Review pull request
Command | Action |
---|---|
bb pr review --id 1 --action approve |
marks the pull request as APPROVED |
bb pr review --id 1 --action unapprove |
marks the pull request as UNAPPROVED |
bb pr review --id 1 --action needs_work |
marks the pull request as NEEDS WORK |
Merge pull request
Command | Action |
---|---|
bb pr merge --id 1 |
Validates pull request merge conditions and prompts for merge |
bb pr merge --id 1 --rebase |
adds optional rebase [Default: False] |
bb pr merge --id 1 --delete-source-branch |
deletes source branch after merge, [Default: False], If false will prompt for deletion |
- This utility is tested with bitbucket enterprise version 6.10.10 and 8.19
- I have personally tested it in Linux, Windows(Powershell and Command Prompt), MacOS and GIT Bash and it works flawlessly
- In case if your ID gets locked the token wont work, you may need to reset your ID (Token can remain the same)
- At times if there are frequent account lockouts, Bitbucket will prompt you to enter CAPTCHA, you may need to relogin with CAPTCHA validation in your broswer once else connection will fail
bbcli wouldn't be possible if not for the awesome open-source tools made avaiable.
A huge thanks to,
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.