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?
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:
#!/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.