diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index cd500e360d..cc3133dc72 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -1,5 +1,4 @@ def action_test_frontend_ct_build = false -def action_pull_cache = false def action_build_deps = false def action_copy_external_pages = false def action_build_dev = false @@ -8,7 +7,6 @@ def action_build_webpack = false def action_test_acceptance_app_saas = false def action_build_pug = false def action_build_production= false -def action_fetch_sentry_secret = false pipeline { agent { @@ -31,7 +29,7 @@ pipeline { AR_REPO_LOCATION = 'us-east1' AR_URL = 'us-east1-docker.pkg.dev/overleaf-ops/ol-docker' DOCKER_COMPOSE_FLAGS = '-f docker-compose.ci.yml' - BRANCH_NAME = "${CHANGE_BRANCH || GIT_BRANCH.replace('origin/', '')}" + BRANCH_NAME = "${GIT_BRANCH.replace('origin/', '')}" COMMIT_SHA = "${GIT_COMMIT}" SHORT_SHA = "${GIT_COMMIT.take(7)}" CDN_STAG = "gs://ol-stag-web-assets-1" @@ -51,14 +49,6 @@ pipeline { } } } - stage('Pull cache') { - steps { - sh 'docker pull ${AR_URL}/${IMAGE_NAME}:main-deps' - script { - action_pull_cache = true - } - } - } stage('Prefetch Tests Images') { steps { dir('services/web') { @@ -68,11 +58,6 @@ pipeline { } stage('Build Deps') { steps { - script { - waitUntil { - return action_pull_cache - } - } dir('services/web') { sh 'make build_deps' } @@ -420,7 +405,7 @@ pipeline { steps { script { waitUntil { - return action_build_webpack & action_build_pug + return action_build_webpack && action_build_pug } } dir('services/web') { @@ -431,37 +416,23 @@ pipeline { } } } - stage('Fetch Sentry Secret') { + stage('Sentry Upload') { steps { script { waitUntil { - return action_build_webpack & action_build_production + return action_build_webpack && action_build_production } } dir('services/web') { sh 'gcloud secrets versions access latest --secret=web-sentryclirc > .sentryclirc' - } - script { - action_fetch_sentry_secret = true + sh 'make sentry_upload' } } - } - stage('Sentry Upload') { - agent { - docker { - image 'getsentry/sentry-cli:2.16.1' - args '--entrypoint=' - reuseNode true + post { + cleanup { + dir('services/web') { + sh 'rm -f .sentryclirc' } - } - steps { - script { - waitUntil { - return action_fetch_sentry_secret - } - } - dir('services/web') { - sh 'bin/sentry_upload' } } } diff --git a/services/web/Makefile b/services/web/Makefile index dd80ef5a3e..63377ff26f 100644 --- a/services/web/Makefile +++ b/services/web/Makefile @@ -1,7 +1,8 @@ DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml BUILD_NUMBER ?= local -BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) +export BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) +export COMMIT_SHA ?= $(shell git rev-parse HEAD) PROJECT_NAME = web BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]') PWD = $(shell pwd) @@ -569,6 +570,17 @@ build: publish: docker push $(IMAGE_REPO_FINAL) +SENTRY_IMAGE=getsentry/sentry-cli:2.16.1 +sentry_prefetch: + docker pull $(SENTRY_IMAGE) + +sentry_upload: + docker run --rm \ + --volume $(PWD):$(PWD) --workdir $(PWD) \ + --env BRANCH_NAME --env SENTRY_RELEASE \ + --entrypoint bin/sentry_upload \ + $(SENTRY_IMAGE) + tar: COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) run --rm tar COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down -v -t 0 diff --git a/services/web/bin/sentry_upload b/services/web/bin/sentry_upload index ad19a6cf60..45a2a9336a 100755 --- a/services/web/bin/sentry_upload +++ b/services/web/bin/sentry_upload @@ -1,13 +1,15 @@ #!/bin/sh set -e -if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "main" ]]; then +echo "BRANCH_NAME=$BRANCH_NAME" +echo "SENTRY_RELEASE=$SENTRY_RELEASE" + +if [[ "$BRANCH_NAME" == "main" ]]; then rm -rf sentry_upload mkdir sentry_upload tar --directory sentry_upload -xf build.tar cd sentry_upload/public - SENTRY_RELEASE=${COMMIT_SHA} sentry-cli releases new "$SENTRY_RELEASE" sentry-cli releases set-commits --auto "$SENTRY_RELEASE" sentry-cli sourcemaps upload --release="$SENTRY_RELEASE" . @@ -15,4 +17,6 @@ if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "main" ]]; then cd ../.. rm -rf sentry_upload +else + echo "Not on main branch. Skipping sentry upload." fi