A command line tool to help access the Bitbucket API. It brings Pipelines, pull requests and other Bitbucket features to the terminal. All which come with command completion
After installation you need to add your username (not email) and bitbucket generated password in your config file %HOMEDIR%/.bitbucketcmd.json
You can use the setup commandline to input the values instead of editing the file directly
bitbucket setup password
bitbucket setup token{
"password": "",
"user": ""
}or via repo access token https://bitbucket.org/$REPO/admin/access-tokens
{
"token":""
}Permission should be to have READ/WRITE for pipelines, pull-requests
https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication
All commands that run on repos will automaticlly asign the repo to current directory remote origin. Other wise you can use the --repo flag to set a repo
List pipelines
Usage
bitbucket pipelines
bitbucket pipelines -p 2Flags
| Name | Description | Default |
|---|---|---|
--page -p |
Current page pagination | 1 |
Fetches pipeline details Usage
bitbucket pipelines $PIPELINE_IDExample
bitbucket pipelines 12
bitbucket pipelines 12 -d #For detailed view including script You can use the pipeline uuid or build number
| Name | Description | Default |
|---|---|---|
--detailed -d |
Includes pipeline scripts steps | 1 |
You can run a pipeline by specifying the pipeline using the --pipeline -p flag and which branch (--branch -b) or which commit (--commit -c) to run it on
Example
bitbucket pipelines run -p deploy-to-staging -b master
bitbucket pipelines run -p custom:deploy-to-staging -c cba0e8d21da448f1264351ba2ebe5545958aa2abIf the pipeline is custom it can be named without a prefix If it is triggered by a tag or branch you can specify it by adding the tirgger as prefix
bitbucket pipelines run -p branches:deploy-from-master -b master
bitbucket pipelines run -p tags:release-to-prod -c cba0e8d21da448f1264351ba2ebe5545958aa2ab| Name | Description | Example |
|---|---|---|
--pipeline -p |
Pipeline name | deploy-to-staging |
--branch -b |
Targeted branch name | master |
--commit -c |
Targeted commit name | cba0e8d21da448f1264351ba2ebe5545958aa2ab |
--variables -v |
Targeted commit name | [{ "key": "var1key", "value": "var1value", "secured": true}] |
Gets pipeline's step log
Usage
bitbucket pipelines step -p $PIPELINE_ID -s $STEP_ID Flags
| Name | Description | Example |
|---|---|---|
--pipeline -p |
Pipeline Id or build number | 1 |
--step -s |
step uuid | {1791efee-9e20-4c60-8a6a-bc1b071a15cc} |
Stop pipeline
Usage
bitbucket pipelines stop $PIPELINE_IDLists pull requests
Usage
bitbucket pr
bitbucket pr -p $PAGE_NUMBER
bitbucket pr -s MERGEDFlags
| Name | Description | Default |
|---|---|---|
--page -p |
Current page pagination | 1 |
--state -s |
PR state | OPEN |
Fetches pull request details
Usage
bitbucket pr $PR_IDExample
bitbucket pr 12
bitbucket pr 12 -d #For detailed view including script Merges pull request
Usage
bitbucket pr merge $PR_ID
bitbucket pr merge $PR_ID -m $MERGE_MESSAGE
bitbucket pr merge $PR_ID -s $MERGE_STRATEGY #specifying merge strategy [fast_forward, merge_commit, squash]
bitbucket pr merge $PR_ID -c #closes sourceExample
bitbucket pr merge 12
bitbucket pr merge 12 -c
bitbucket pr merge 12 -m "Closing message" Flags
| Name | Description | Default |
|---|---|---|
--message -m |
Merge message | '' |
--strategy -s |
Merge strategy | OPEN |
--close-source -c |
Close source | false |
Declines a pull request
Usage
bitbucket pr decline $PR_IDExample
bitbucket pr decline 12 Lists Environments
Usage
bitbucket envs