Skip to content

Commit

Permalink
Merge pull request #30 from linuxbandit/feature/improve-sentry
Browse files Browse the repository at this point in the history
feat: sentry uses cli instead of broken api
  • Loading branch information
gadiener authored Apr 27, 2020
2 parents 8c7f1a6 + 12d12b0 commit c3491c6
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 47 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,15 @@ include:
stages:
- notify
variables:
SENTRY_AUTH_TOKEN: my-sentry-user-token
SENTRY_URL: my-sentry.example.net
SENTRY_PROJECT: my-sentry-project
SENTRY_ORG: my-sentry-org
```

This stage makes an API call to the project-specific sentry webhook, in order to announce a new release [as per the docs](https://docs.sentry.io/workflow/releases/?platform=javascript#using-the-api).
This stage uses `getsentry/sentry-cli:1.52.3`, in order to announce a new release [as per the docs](https://docs.sentry.io/workflow/releases/?platform=javascript#using-the-cli).

# General advices

Expand Down
2 changes: 1 addition & 1 deletion bucket-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/bucket-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/bucket-quality.yml'

deploy:production:
extends: .deploy
Expand Down
2 changes: 1 addition & 1 deletion bucket-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/bucket.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/bucket.yml'

deploy:quality:
extends: .deploy
Expand Down
2 changes: 1 addition & 1 deletion cloudrun-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/cloudrun-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/cloudrun-quality.yml'

deploy:production:
extends: deploy:quality
Expand Down
4 changes: 2 additions & 2 deletions cloudrun-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/cloudrun.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/cloudrun.yml'

deploy:quality:
extends: .cloudrun:deploy
Expand Down
2 changes: 1 addition & 1 deletion docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/docker.yml'

build:
stage: build
Expand Down
2 changes: 1 addition & 1 deletion helm-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/helm-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/helm-quality.yml'

# EUROPE
deploy:production:europe:helm:
Expand Down
4 changes: 2 additions & 2 deletions helm-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/helm.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/helm.yml'

deploy:quality:helm:
variables:
Expand Down
2 changes: 1 addition & 1 deletion helm-regional.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/helm-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/helm-quality.yml'

deploy:production:helm:
extends: .deploy:production:helm
Expand Down
2 changes: 1 addition & 1 deletion kubernetes-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/kubernetes-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/kubernetes-quality.yml'

# EUROPE
deploy:production:europe:image:
Expand Down
4 changes: 2 additions & 2 deletions kubernetes-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/kubernetes.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/kubernetes.yml'

deploy:quality:image:
variables:
Expand Down
2 changes: 1 addition & 1 deletion kubernetes-regional.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/kubernetes-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/kubernetes-quality.yml'

deploy:production:image:
extends: .deploy:production:image
Expand Down
2 changes: 1 addition & 1 deletion kubernetes-task-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/kubernetes-task-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/kubernetes-task-quality.yml'

task:production:
extends: .task
Expand Down
2 changes: 1 addition & 1 deletion kubernetes-task-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/kubernetes-task.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/kubernetes-task.yml'

task:quality:
extends: .task
Expand Down
80 changes: 56 additions & 24 deletions sentry.yml
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}!"
2 changes: 1 addition & 1 deletion serverless-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/serverless.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/serverless.yml'

# EUROPE
deploy:production:europe:
Expand Down
2 changes: 1 addition & 1 deletion serverless-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/serverless.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/serverless.yml'

deploy:quality:
extends: .serverless:deploy
Expand Down
2 changes: 1 addition & 1 deletion serverless-regional.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/serverless.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/serverless.yml'

deploy:production:
extends: .serverless:deploy
Expand Down
2 changes: 1 addition & 1 deletion ssh-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/ssh-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/ssh-quality.yml'

ssh:production:
extends: .ssh:exec
Expand Down
2 changes: 1 addition & 1 deletion ssh-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/ssh.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/ssh.yml'

ssh:quality:
extends: .ssh:exec
Expand Down
2 changes: 1 addition & 1 deletion test-unit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.10.0/templates/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.11.0/templates/docker.yml'

test:unit:
extends: .docker
Expand Down

0 comments on commit c3491c6

Please sign in to comment.