| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- // Initialize variables to signal that a given stage finished.
- // We use them to build a graph of interconnected steps/dependencies.
- // - Incoming edges use "waitUntil" and reference the given variables of dependencies.
- // - Outgoing edges set the given variable to true.
- def action_test_frontend_ct_build = false
- def action_build_deps = false
- def action_copy_external_pages = false
- def action_build_dev = false
- def action_test_acceptance_app_server_pro = false
- def action_build_webpack = false
- def action_test_acceptance_app_saas = false
- def action_build_pug = false
- def action_build_production = false
- pipeline {
- agent {
- node {
- // Select a VM with the given tabel.
- label 'jenkins-agent-web'
- // Use the monorepo checkout in /workspace.
- customWorkspace '/workspace'
- }
- }
- options {
- // Print timestamp next to each log line.
- timestamps()
- // Abort build after hitting first failure.
- parallelsAlwaysFailFast()
- retry(3)
- timeout(time: 15, unit: 'MINUTES')
- }
- environment {
- IMAGE_NAME = 'web'
- PROJECT_NAME = 'web'
- IMAGE_REPO = 'us-east1-docker.pkg.dev/overleaf-ops/ol-docker/web'
- 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 = "${env.CHANGE_BRANCH ? env.CHANGE_BRANCH : env.BRANCH_NAME}"
- JENKINS_BUILD_NUMBER = "${BUILD_NUMBER}" // preserve original BUILD_NUMBER
- BUILD_NUMBER = "${SHORT_SHA}_${BUILD_NUMBER}" // mimic the format used for Cloud Build
- COMMIT_SHA = "${GIT_COMMIT}"
- SHORT_SHA = "${GIT_COMMIT.take(7)}"
- CDN_STAG = "gs://ol-stag-web-assets-1"
- CDN_PROD = "gs://mgcp-1117973-ol-prod-web-assets-1"
- }
- stages {
- // Retries will use the same pipeline instance. Reset the vars.
- stage('Reset vars') {
- steps {
- script {
- action_test_frontend_ct_build = false
- action_build_deps = false
- action_copy_external_pages = false
- action_build_dev = false
- action_test_acceptance_app_server_pro = false
- action_build_webpack = false
- action_test_acceptance_app_saas = false
- action_build_pug = false
- action_build_production = false
- }
- }
- }
- stage ('Build, Test and Push') {
- parallel {
- stage('Copy external pages') {
- steps {
- dir('services/web') {
- sh 'bin/copy_external_pages'
- script {
- action_copy_external_pages = true
- }
- }
- }
- }
- stage('Prefetch Tests Images') {
- steps {
- dir('services/web') {
- sh 'docker compose -f docker-compose.ci.yml pull --quiet test_frontend_ct mongo redis_test ldap saml'
- }
- }
- }
- stage('Build Deps') {
- steps {
- dir('services/web') {
- sh 'make build_deps'
- }
- script {
- action_build_deps = true
- }
- }
- }
- stage('Push Deps') {
- steps {
- script {
- waitUntil {
- return action_build_deps
- }
- }
- dir('services/web') {
- sh 'docker push ${AR_URL}/${IMAGE_NAME}:${BRANCH_NAME}-deps'
- }
- }
- }
- stage('Build Dev') {
- steps {
- script {
- waitUntil {
- return action_build_deps && action_copy_external_pages
- }
- }
- dir('services/web') {
- sh 'make build_dev'
- }
- script {
- action_build_dev = true
- }
- }
- }
- stage ('Format') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh 'make format_in_docker'
- }
- }
- }
- stage('Lint') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh 'make lint_in_docker'
- }
- }
- }
- stage('Shellcheck') {
- steps {
- dir('services/web') {
- sh 'make shellcheck'
- }
- }
- }
- stage('Acceptance SaaS') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh 'make test_acceptance_app_saas'
- }
- script {
- action_test_acceptance_app_saas = true
- }
- }
- }
- stage('Acceptance Server CE') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_app_server_ce"
- }
- }
- }
- stage('Acceptance Server Pro') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_app_server_pro"
- }
- script {
- action_test_acceptance_app_server_pro = true
- }
- }
- }
- stage('test_acceptance_modules_merged_saas_1') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_modules_merged_saas_1"
- }
- }
- }
- stage('test_acceptance_modules_merged_saas_2') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_modules_merged_saas_2"
- }
- }
- }
- stage('test_acceptance_modules_merged_saas_3') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_modules_merged_saas_3"
- }
- }
- }
- stage('test_acceptance_modules_merged_saas_4') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_modules_merged_saas_4"
- }
- }
- }
- stage('test_acceptance_modules_merged_server_ce') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_modules_merged_server_ce"
- }
- }
- }
- stage('test_acceptance_modules_merged_server_pro') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_acceptance_modules_merged_server_pro"
- }
- }
- }
- stage('test_frontend') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_frontend"
- }
- }
- }
- stage('test_writefull') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_writefull"
- }
- }
- }
- stage('test_frontend_ct_build') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make build_test_frontend_ct"
- }
- script {
- action_test_frontend_ct_build = true
- }
- }
- }
- stage('test_frontend_ct_core_other') {
- environment {
- CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT = '120000'
- }
- steps {
- script {
- waitUntil {
- return action_test_frontend_ct_build
- }
- }
- dir('services/web') {
- sh "make test_frontend_ct_core_other"
- }
- }
- }
- stage('test_frontend_ct_core_features') {
- environment {
- CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT = '120000'
- }
- steps {
- script {
- waitUntil {
- return action_test_frontend_ct_build
- }
- }
- dir('services/web') {
- sh "make test_frontend_ct_core_features"
- }
- }
- }
- stage('test_frontend_ct_modules') {
- environment {
- CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT = '120000'
- }
- steps {
- script {
- waitUntil {
- return action_test_frontend_ct_build
- }
- }
- dir('services/web') {
- sh "make test_frontend_ct_modules"
- }
- }
- }
- stage('test_frontend_ct_editor_visual') {
- steps {
- script {
- waitUntil {
- return action_test_frontend_ct_build
- }
- }
- dir('services/web') {
- sh "make test_frontend_ct_editor_visual"
- }
- }
- }
- stage('test_frontend_ct_editor_other') {
- steps {
- script {
- waitUntil {
- return action_test_frontend_ct_build
- }
- }
- dir('services/web') {
- sh "make test_frontend_ct_editor_other"
- }
- }
- }
- stage('Test Unit ESM') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_unit_esm"
- }
- }
- }
- stage('Test Unit Mocha') {
- steps {
- script {
- waitUntil {
- return action_build_dev
- }
- }
- dir('services/web') {
- sh "make test_unit_mocha"
- }
- }
- }
- stage('Build Webpack') {
- steps {
- script {
- waitUntil {
- return action_build_dev && action_test_acceptance_app_server_pro
- }
- }
- dir('services/web') {
- sh 'make build_webpack'
- }
- script {
- action_build_webpack = true
- }
- }
- }
- stage('Build Pug') {
- steps {
- script {
- waitUntil {
- return action_build_dev && action_test_acceptance_app_server_pro
- }
- }
- dir('services/web') {
- sh 'make build_pug'
- }
- script {
- action_build_pug = true
- }
- }
- }
- stage('CDN Upload Image') {
- steps {
- script {
- waitUntil {
- return action_build_webpack
- }
- }
- dir('services/web') {
- sh 'make tar'
- sh 'bin/cdn_upload'
- }
- }
- }
- stage('Build Production') {
- steps {
- script {
- waitUntil {
- return action_build_webpack && action_build_pug
- }
- }
- dir('services/web') {
- sh 'make build'
- }
- script {
- action_build_production = true
- }
- }
- }
- stage('Sentry Upload') {
- steps {
- script {
- waitUntil {
- return action_build_webpack && action_build_production
- }
- }
- dir('services/web') {
- sh 'gcloud secrets versions access latest --secret=web-sentryclirc > .sentryclirc'
- sh 'make sentry_upload'
- }
- }
- post {
- cleanup {
- dir('services/web') {
- sh 'rm -f .sentryclirc'
- }
- }
- }
- }
- }
- }
- stage('Push Production') {
- steps {
- dir('services/web') {
- sh 'make publish'
- }
- }
- }
- }
- post {
- // Ensure tear down of test containers, then run general Jenkins VM cleanup.
- cleanup {
- dir('services/web') {
- sh 'make clean'
- }
- sh 'make clean_jenkins'
- }
- }
- }
- // vim: set ft=groovy :
|