Forward build status and step output from Bitbucket Pipelines to your BunnyLogs stream using plain curl — no extra dependencies required.
Each pipeline step can POST messages directly to your logspace's HTTP endpoint. Store your logspace UUID as a Bitbucket repository variable so it is never exposed in your repository.
https://bunnylogs.com/live/<uuid>).BL_UUID with the UUID as its value. Check Secured to mask it in logs.curl steps to your bitbucket-pipelines.yml (see examples below).Use an after-script block to report the final outcome regardless of whether the step succeeded or failed:
pipelines:
default:
- step:
name: Build and test
script:
- npm test
after-script:
- |
if [ $BITBUCKET_EXIT_CODE -eq 0 ]; then
LEVEL="INFO"
STATUS="passed"
else
LEVEL="ERROR"
STATUS="failed"
fi
curl -s \
-d "message=Build $STATUS: $BITBUCKET_REPO_FULL_NAME ($BITBUCKET_BRANCH)" \
-d "level=$LEVEL" \
-d "program=bitbucket/$BITBUCKET_REPO_FULL_NAME" \
https://bunnylogs.com/live/$BL_UUID
Capture a step's output with tee and forward each line as a separate log entry:
- step:
name: Run tests
script:
- npm test 2>&1 | tee /tmp/test.log
after-script:
- |
while IFS= read -r line; do
curl -s \
-d "message=$line" \
-d "level=INFO" \
-d "program=bitbucket/tests" \
https://bunnylogs.com/live/$BL_UUID
done < /tmp/test.log
Post at the beginning and end of a step to make it easy to spot where each run begins in the log stream:
- step:
name: Deploy
script:
- |
curl -s \
-d "message=Started: deploy $BITBUCKET_REPO_FULL_NAME @ $BITBUCKET_COMMIT" \
-d "level=INFO" \
-d "program=bitbucket/$BITBUCKET_REPO_FULL_NAME" \
https://bunnylogs.com/live/$BL_UUID
- ./deploy.sh
after-script:
- |
if [ $BITBUCKET_EXIT_CODE -eq 0 ]; then LEVEL="INFO"; else LEVEL="ERROR"; fi
curl -s \
-d "message=Finished (exit $BITBUCKET_EXIT_CODE): deploy $BITBUCKET_REPO_FULL_NAME" \
-d "level=$LEVEL" \
-d "program=bitbucket/$BITBUCKET_REPO_FULL_NAME" \
https://bunnylogs.com/live/$BL_UUID
| Variable | Value |
|---|---|
$BITBUCKET_REPO_FULL_NAME | Workspace and repository slug, e.g. myteam/myrepo |
$BITBUCKET_BRANCH | Branch being built |
$BITBUCKET_COMMIT | Full commit SHA |
$BITBUCKET_BUILD_NUMBER | Incrementing pipeline build number |
$BITBUCKET_EXIT_CODE | Exit code of the last script command — only available in after-script |
$BITBUCKET_PIPELINE_UUID | Unique ID for this pipeline run |
| BunnyLogs field | Recommended value |
|---|---|
message | Build status or captured log line |
program | bitbucket/<workspace>/<repo> |
level | INFO on success, ERROR on failure |
timestamp | Omit — defaults to server receipt time |
after-script rather than a final script entry for notifications — after-script always runs even when earlier commands fail, and provides $BITBUCKET_EXIT_CODE.-s flag on curl suppresses progress output so it does not clutter the Pipelines log.while read makes each line individually searchable in BunnyLogs.program field to distinguish sources. Define BL_UUID as a workspace variable to share it across all repos in your workspace.level=ERROR and program contains bitbucket/ to get notified on build failures via Slack, Telegram, or Discord.