mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[web] tweaks for jenkins pipeline (#27952)
* [web] move sentry upload into a Makefile target * [web] fix typos in jenkins pipeline * [web] fix BRANCH_NAME for PR builds This is currently "true". Just use PR-xxx for now. * [web] remove explicit pull of main-deps for Jenkins In Jenkins we do not need to wait for the cloud-builder image. The docker build can start right away. Let docker validate the remote cache and pull it if needed. * [packer] jenkins-worker: prefetch sentry image * [packer] jenkins-worker: switch to production AR * [packer] jenkins-worker: wait for monorepo setup before pulling sentry * [web] cloudbuild: fix directory for prefetch_sentry GitOrigin-RevId: ec394bbf51efd516f0ade8813014dec9b63fb732
This commit is contained in:
47
services/web/Jenkinsfile
vendored
47
services/web/Jenkinsfile
vendored
@@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user