https://github.com/danielwhatmuff/bitbucket-build-reporter
Report build state to Bitbucket Cloud from CI jobs
https://github.com/danielwhatmuff/bitbucket-build-reporter
bitbucket bitbucket-cloud build build-status cd ci jenkins jenkins-pipeline reporter
Last synced: about 1 month ago
JSON representation
Report build state to Bitbucket Cloud from CI jobs
- Host: GitHub
- URL: https://github.com/danielwhatmuff/bitbucket-build-reporter
- Owner: danielwhatmuff
- Created: 2018-05-11T16:07:15.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-29T09:41:28.000Z (about 8 years ago)
- Last Synced: 2025-08-11T18:36:42.912Z (10 months ago)
- Topics: bitbucket, bitbucket-cloud, build, build-status, cd, ci, jenkins, jenkins-pipeline, reporter
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bitbucket Cloud Build Status Reporter
## Update the Bitbucket build statuses for commits from your CI jobs.



### Benefits
* Block pull requests from being merged if there is a failed build
* Link to the relevant build logs from within Bitbucket UI
### Notes
* Commit will be determined from the current directory if not supplied on command line
* URL and build number will default to jenkins environment variables if not supplied on command line
* Requires username and password with `repository` scope permission to access the required [API method](https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build)
### Usage example
* If you use Travis CI (.org)
```yaml
...
before_script:
- bb-report -c $TRAVIS_COMMIT -U "https://travis-ci.org/$TRAVIS_REPO_SLUG/builds/$TRAVIS_BUILD_ID" -n $TRAVIS_BUILD_NUMBER -s INPROGRESS -r -u $BITBUCKET_USERNAME -p $BITBUCKET_PASSWORD -o
script:
- python your-tests.py
after_failure:
- bb-report -c $TRAVIS_COMMIT -U "https://travis-ci.org/$TRAVIS_REPO_SLUG/builds/$TRAVIS_BUILD_ID" -n $TRAVIS_BUILD_NUMBER -s FAILED -r -u $BITBUCKET_USERNAME -p $BITBUCKET_PASSWORD -o
after_success:
- bb-report -c $TRAVIS_COMMIT -U "https://travis-ci.org/$TRAVIS_REPO_SLUG/builds/$TRAVIS_BUILD_ID" -n $TRAVIS_BUILD_NUMBER -s SUCCESSFUL -r -u $BITBUCKET_USERNAME -p $BITBUCKET_PASSWORD -o
...
```
### Reference
```
usage: bb-report [-h] -o ORG -r REPO [-c COMMIT] [-U URL] [-n NUMBER] -s
{INPROGRESS,SUCCESSFUL,FAILED} -u USERNAME -p PASSWORD [-d]
Bitbucket Cloud Build Status Notifier
optional arguments:
-h, --help show this help message and exit
-o ORG, --org ORG Bitbucket org
-r REPO, --repo REPO Repository name
-c COMMIT, --commit COMMIT
Commit sha
-U URL, --url URL Build URL
-n NUMBER, --number NUMBER
CI build number
-s {INPROGRESS,SUCCESSFUL,FAILED}, --state {INPROGRESS,SUCCESSFUL,FAILED}
State of the build
-u USERNAME, --username USERNAME
Username for bitbucket
-p PASSWORD, --password PASSWORD
Password for bitbucket
-d, --debug Debug mode
```
### Sanity test it against your Bitbucket account locally
```
$ pip install bitbucket-build-reporter
$ cd your-repo/ # Required for determining a valid commit sha
$ bb-report -U 'https://your-ci.com' -n 123 -s INPROGRESS -r -u -p -o
```