forked from gadiener/ci-templates
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from linuxbandit/feature/improve-sentry
feat: sentry uses cli instead of broken api
- Loading branch information
Showing
21 changed files
with
85 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,68 @@ | ||
notify_sentry: | ||
image: gdiener/ci-image-gcp:v1.0.1 | ||
stage: notify | ||
.sentry: | ||
image: getsentry/sentry-cli:1.52.3 | ||
only: | ||
- /^v.+$/i | ||
- master | ||
allow_failure: true | ||
when: on_success | ||
script: | ||
- | | ||
if [ -z "${SENTRY_API_URL}" ]; then | ||
echo | ||
echo "-> [WARNING] Missing 'SENTRY_API_URL' variable!" | ||
echo | ||
exit 1 | ||
fi | ||
- &check-set-variables | | ||
# CHECK VARIABLES PHASE | ||
for var in "SENTRY_AUTH_TOKEN" "SENTRY_URL" "SENTRY_ORG" "SENTRY_PROJECT"; do | ||
if [ -z "${!var}" ]; then | ||
echo "Missing '${var}' variable!" | ||
exit 1 | ||
fi | ||
done | ||
|
||
ENVIRONMENT="production" | ||
if [ -z "${CI_COMMIT_TAG}" ]; then | ||
CI_COMMIT_TAG=${CI_COMMIT_SHA} | ||
ENVIRONMENT="quality" | ||
fi | ||
|
||
PAYLOAD="{ \"version\": \"${CI_COMMIT_TAG}\" }" | ||
sentry-cli info | ||
|
||
STATUS_CODE=$(curl -sS -o /tmp/response.txt --write-out "%{http_code}" -H 'Content-Type: application/json' -X POST -d "${PAYLOAD}" "${SENTRY_API_URL}") | ||
sentry:release:set: | ||
extends: .sentry | ||
stage: build | ||
script: | ||
- *check-set-variables | ||
- | | ||
#SET NEW RELEASE | ||
if [[ "${STATUS_CODE}" -ne 201 ]] ; then | ||
echo "Sentry webhook returned '${STATUS_CODE}' error!" | ||
sentry-cli releases new "${CI_COMMIT_TAG}" | ||
if [ -n "${FEAT_SENTRY_SETCOMMITS}" ]; then | ||
echo | ||
echo "Response:" | ||
cat /tmp/response.txt | ||
echo "-> [INFO] variable 'FEAT_SENTRY_SETCOMMITS' for experimental feature enabled!" | ||
echo | ||
echo "Payload: ${PAYLOAD}" | ||
exit 1 | ||
sentry-cli releases set-commits "${CI_COMMIT_TAG}" --auto | ||
fi | ||
echo "Sentry was notified of the change!" | ||
when: on_success | ||
allow_failure: true | ||
only: | ||
- /^v.+$/i | ||
- master | ||
echo "Sentry release set to ${CI_COMMIT_TAG}!" | ||
sentry:release:finalize: | ||
extends: .sentry | ||
stage: deploy | ||
script: | ||
- *check-set-variables | ||
- | | ||
#FINALISE RELEASE | ||
sentry-cli releases finalize "${CI_COMMIT_TAG}" | ||
echo "Sentry release finalized to ${CI_COMMIT_TAG}!" | ||
sentry:notify: | ||
extends: .sentry | ||
stage: notify | ||
script: | ||
- *check-set-variables | ||
- | | ||
#SET NEW DEPLOY | ||
sentry-cli releases deploys "${CI_COMMIT_TAG}" new -e "${ENVIRONMENT}" | ||
echo "Sentry was notified that release ${CI_COMMIT_TAG} was set for ${ENVIRONMENT}!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters