Bitbucket Release Pipe

Hi,

The SENTRY_RELEASE variable is by default the $BITBUCKET_COMMIT.
Is there a way to override this?
I would like it to match the release from Sentry.init({ release: 'project@1.0.3' })

If there’s no way, would it be possible to make it an optional pipe variable instead then?

- pipe: sentryio/sentry-new-release:0.3.0
  variables:
    SENTRY_AUTH_TOKEN: '<string>'
    SENTRY_ORG: '<string>'
    SENTRY_PROJECT: '<string>'
    # ENVIRONMENT: '<string>' # Optional.
    # RELEASE: '<string>' # Optional.
1 Like

Julien,

Not sure if you still need this. However, for anybody who stumbles across this in the future…

https://bitbucket.org/sentryio/sentry-new-release/src/master/

I took the pipe.sh & common.sh and committed them to my repository, then I run the scripts manually in my bitbucket-pipelines.yml. I added the requisite environment variables in the repository settings. Here’s my implementation:

bitbucket-pipelines.yml

definitions:
  steps:
    - step: &build-publish
        name: Publish and release Docker images
        script:
          ...
          - export RELEASE=<PROJECT>@<VERSION>
          - chmod +x ./scripts/bitbucket/sentry-release.sh
          - curl -sL https://sentry.io/get-cli/ | bash
          - ./scripts/bitbucket/sentry-release.sh

sentry-release.sh (a.k.a. pipe.sh)

#!/usr/bin/env bash

source "$(dirname "$0")/common.sh"

enable_debug
extra_args=""
if [[ "${SENTRY_DEBUG}" == "true" ]]; then
  extra_args="--verbose"
  export SENTRY_LOG_LEVEL=debug
fi

info "Executing the pipe..."

# Required parameters
SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN:?'SENTRY_AUTH_TOKEN variable missing.'}
SENTRY_PROJECT=${SENTRY_PROJECT:?'SENTRY_PROJECT variable missing.'}
SENTRY_ORG=${SENTRY_ORG:?'SENTRY_ORG variable missing.'}

# Optional parameters
SHOULD_FINALIZE=${FINALIZE:-"true"}
ENVIRONMENT=${SENTRY_ENVIRONMENT}
RELEASE=${RELEASE}

export SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
export SENTRY_ORG=$SENTRY_ORG
export SENTRY_RELEASE=${RELEASE:?BITBUCKET_COMMIT}

sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits --auto $SENTRY_RELEASE
if [[ -n "${ENVIRONMENT}" ]]; then
  sentry-cli releases deploys $SENTRY_RELEASE new -e $ENVIRONMENT
fi
if [[ "${SHOULD_FINALIZE}" == "true" ]]; then
  sentry-cli releases finalize $SENTRY_RELEASE
fi

It largely remained the same, but I defaulted the SENTRY_RELEASE variable to take the RELEASE variable from my bitbucket-pipelines.yml and otherwise default to the Bitbucket commit if the RELEASE variable is not available.