A lightweight command-line interface for Bitbucket Cloud. Wraps the Bitbucket REST API for common operations like managing pipelines, pull requests, and repositories.
No dependencies beyond curl and jq. Works on macOS, Linux, and WSL.
- Pipelines: List, view, watch, trigger, and stop pipeline builds
- Pull Requests: Create, view, approve, merge, and manage PRs
- Repositories: List repos, view details, browse branches
- Browser Integration: Quick-open any resource in your browser
bash(4.0+)curl- usually pre-installed on macOS/Linuxjq- JSON processor (install instructions)
macOS (Homebrew):
brew install jqUbuntu/Debian:
sudo apt-get install jqFedora/RHEL:
sudo dnf install jqWindows (via Chocolatey):
choco install jq-
Clone this repository:
git clone https://github.com/yourusername/bitbucket-cli.git cd bitbucket-cli -
Make the script executable:
chmod +x bb
-
Symlink to your PATH:
ln -s "$(pwd)/bb" /usr/local/bin/bbOr add the directory to your PATH:
echo 'export PATH="$PATH:/path/to/bitbucket-cli"' >> ~/.bashrc
Create a config file at ~/.config/bb/config:
mkdir -p ~/.config/bb
cat > ~/.config/bb/config <<EOF
BB_USER=your-email@example.com
BB_TOKEN=your-api-token
BB_WORKSPACE=your-workspace
EOF- Go to Atlassian API Tokens
- Click "Create API token"
- Copy the token and set it as
BB_TOKEN - Set
BB_USERto your Bitbucket account email address
Your Bitbucket account needs these workspace permissions:
| Feature | Required Permission |
|---|---|
| View pipelines, PRs, repos | Read access to repositories |
| Trigger/stop pipelines | Read + Write access to Pipelines |
| Create/approve/merge PRs | Read + Write access to Pull Requests |
Note: Atlassian API tokens inherit your account's workspace permissions. If you can perform an action in the Bitbucket UI, the CLI can do it too.
You can also set configuration via environment variables:
export BB_USER="your-email@example.com"
export BB_TOKEN="your-api-token"
export BB_WORKSPACE="your-workspace"bb <command> [options]
bb pipelines [repo] [count] # List recent pipelines (default: 10)
bb pipeline [repo] <number> # Show pipeline details and steps
bb watch [repo] [number] [interval] # Poll pipeline until done (default: 15s)
bb logs [repo] <number> [step] # Show step logs
bb trigger [repo] [branch] [pattern] # Trigger a pipeline run
bb stop [repo] <number> # Stop a running pipeline
bb approve [repo] <number> # Open pipeline in browser (manual steps require UI)bb prs [repo] [state] # List PRs (default: OPEN)
bb pr [repo] <id> # View PR details
bb pr-create [repo] <title> [dest] # Create PR from current branch
bb pr-approve [repo] <id> # Approve a PR
bb pr-merge [repo] <id> [strategy] # Merge a PR (merge_commit|squash|fast_forward)
bb pr-decline [repo] <id> # Decline a PR
bb pr-diff [repo] <id> # Show PR diff
bb pr-comments [repo] <id> # Show PR commentsbb branches [repo] # List branches
bb repos # List workspace repos
bb repo [repo] # Show repo details
bb downloads [repo] # List repo downloads
bb vars [repo] # List pipeline variablesbb open [repo] [section] # Open in browser (pr|pipelines|branches|settings|commits)
bb help # Show help-w, --workspace <name> # Override workspace for this commandWhen inside a git repository with a Bitbucket remote, the [repo] argument is optional - it will be auto-detected from the git remote URL.
# Watch the latest pipeline on current repo
bb watch
# List open PRs
bb prs
# Create a PR from current branch to main
bb pr-create "Add new feature"
# Trigger a custom pipeline with variables
bb trigger my-repo main manual-deploy-prod LAMBDA_NAMES=mci
# View pipeline logs for step 1
bb logs my-repo 42 1
# Open repo settings in browser
bb open my-repo settingsMIT License - see LICENSE for details.