Log Bitbucket CI Build Results in Real Time

Send Bitbucket Pipelines pass/fail notifications to BunnyLogs with a single curl command — no extra dependencies. Get instant Slack, Telegram, or Discord alerts when builds fail.

How it works

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.

Setup
  1. Copy your logspace UUID from the stream URL (https://bunnylogs.com/live/<uuid>).
  2. In your Bitbucket repository go to Repository settings → Pipelines → Repository variables and add a variable named BL_UUID with the UUID as its value. Check Secured to mask it in logs.
  3. Add curl steps to your bitbucket-pipelines.yml (see examples below).
Example — pass/fail notification

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
Example — stream step output line by line

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
Example — start + finish bookends

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
Useful Bitbucket variables
VariableValue
$BITBUCKET_REPO_FULL_NAMEWorkspace and repository slug, e.g. myteam/myrepo
$BITBUCKET_BRANCHBranch being built
$BITBUCKET_COMMITFull commit SHA
$BITBUCKET_BUILD_NUMBERIncrementing pipeline build number
$BITBUCKET_EXIT_CODEExit code of the last script command — only available in after-script
$BITBUCKET_PIPELINE_UUIDUnique ID for this pipeline run
Field mapping
BunnyLogs fieldRecommended value
messageBuild status or captured log line
programbitbucket/<workspace>/<repo>
levelINFO on success, ERROR on failure
timestampOmit — defaults to server receipt time
Notes
  • Use after-script rather than a final script entry for notifications — after-script always runs even when earlier commands fail, and provides $BITBUCKET_EXIT_CODE.
  • The -s flag on curl suppresses progress output so it does not clutter the Pipelines log.
  • Streaming line-by-line output with while read makes each line individually searchable in BunnyLogs.
  • You can use the same UUID across multiple repositories — use the program field to distinguish sources. Define BL_UUID as a workspace variable to share it across all repos in your workspace.
  • Set up an Alert in BunnyLogs matching level=ERROR and program contains bitbucket/ to get notified on build failures via Slack, Telegram, or Discord.