Bitbucket Pipelines

Notify Bugsnag of deploys using Bitbucket Pipelines.

By sending the source revision when you deploy a new version of your app using Bitbucket Pipelines, you’ll be able to see which deploy each error was introduced in and link back to the code in the repo.

Set up Pipeline

  1. Create the following script called in your repo and make sure it has execute permissions.

    #!/bin/bash -e
    # Usage: [release-stage]
    # release-stage           The release stage (Optional, defaults to “production”).
    # Environment variable:
    # BUGSNAG_API_KEY         The API key associated with the project.
    if [ -z "$RELEASE_STAGE" ]; then
    if [ -z $BUGSNAG_API_KEY ]; then
      echo "Bugsnag API key must be set"
      exit 1
    curl \
      -X POST \
      -d "apiKey=${BUGSNAG_API_KEY}&releaseStage=${RELEASE_STAGE}&repository=${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}&revision=${BITBUCKET_COMMIT}&branch=\"${BITBUCKET_BRANCH}\""
  2. Define the following environment variable in Bitbucket Repository Settings -> Pipelines -> Environment variables.

    • BUGSNAG_API_KEY - The API key for your Bugsnag project
  3. In bitbucket-pipelines.yml execute the script after a deployment in your build, passing the release stage as an argument to the script. For example, to notify Bugsnag of a deploy to production every time a commit is made to master add the following:

          - step:
               - ./ production