9595 branch ' staging'
9696 branch ' dev'
9797 expression { return env. BRANCH_NAME ==~ / review-.+/ }
98+ expression { return env. BRANCH_NAME ==~ / staging-.+/ }
9899 expression { return env. BRANCH_NAME ==~ / feat-.+/ }
100+ expression { return env. BRANCH_NAME ==~ / alpha-.+/ }
99101 expression { return env. BRANCH_NAME ==~ / claude\/ .+/ }
100102 changeRequest()
101103 }
@@ -218,6 +220,7 @@ BRANCH_NAME=${env.BRANCH_NAME}"""
218220 sh """
219221 sed -i "s/GIT_HASH_PLACEHOLDER/${ GIT_COMMIT_HASH} /g" src/environments/environment.prod.ts
220222 sed -i "s/GIT_HASH_PLACEHOLDER/${ GIT_COMMIT_HASH} /g" src/environments/environment.staging.ts
223+ sed -i "s/GIT_HASH_PLACEHOLDER/${ GIT_COMMIT_HASH} /g" src/environments/environment.alpha.ts
221224 """
222225
223226 sh ' npm run build'
@@ -243,6 +246,14 @@ BRANCH_NAME=${env.BRANCH_NAME}"""
243246 }
244247
245248 stage(' SonarQube Analysis' ) {
249+ when {
250+ not {
251+ anyOf {
252+ expression { return env. BRANCH_NAME ==~ / alpha-.+/ }
253+ expression { return env. BRANCH_NAME . contains(' alpha' ) }
254+ }
255+ }
256+ }
246257 steps {
247258 container(' builder' ){
248259 dir(' elohim-app' ) {
@@ -410,6 +421,13 @@ BRANCH_NAME=${env.BRANCH_NAME}"""
410421 }
411422
412423 stage(' Deploy to Staging' ) {
424+ when {
425+ anyOf {
426+ branch ' staging'
427+ expression { return env. BRANCH_NAME ==~ / staging-.+/ }
428+ expression { return env. BRANCH_NAME ==~ / review-.+/ }
429+ }
430+ }
413431 steps {
414432 container(' builder' ){
415433 script {
@@ -456,55 +474,231 @@ BRANCH_NAME=${env.BRANCH_NAME}"""
456474 }
457475 }
458476
477+ stage(' Deploy to Alpha' ) {
478+ when {
479+ anyOf {
480+ branch ' dev'
481+ expression { return env. BRANCH_NAME ==~ / feat-.+/ }
482+ expression { return env. BRANCH_NAME . contains(' alpha' ) }
483+ }
484+ }
485+ steps {
486+ container(' builder' ){
487+ script {
488+ def props = loadBuildVars()
489+
490+ withBuildVars(props) {
491+ echo " Deploying to Alpha: ${ IMAGE_TAG} "
492+
493+ // Validate configmap
494+ sh '''
495+ kubectl get configmap elohim-config-alpha -n ethosengine || {
496+ echo "❌ ERROR: elohim-config-alpha ConfigMap missing"
497+ exit 1
498+ }
499+ '''
500+
501+ // Update deployment manifest
502+ sh " sed 's/BUILD_NUMBER_PLACEHOLDER/${ IMAGE_TAG} /g' manifests/alpha-deployment.yaml > manifests/alpha-deployment-${ IMAGE_TAG} .yaml"
503+
504+ // Verify the image tag in the manifest
505+ sh """
506+ echo '==== Deployment manifest preview ===='
507+ grep 'image:' manifests/alpha-deployment-${ IMAGE_TAG} .yaml
508+ echo '===================================='
509+ """
510+
511+ // Deploy
512+ sh " kubectl apply -f manifests/alpha-deployment-${ IMAGE_TAG} .yaml"
513+ sh " kubectl rollout restart deployment/elohim-site-alpha -n ethosengine"
514+ sh ' kubectl rollout status deployment/elohim-site-alpha -n ethosengine --timeout=300s'
515+
516+ // Verify the deployment is using the correct image
517+ sh """
518+ echo '==== Verifying deployed image ===='
519+ kubectl get deployment elohim-site-alpha -n ethosengine -o jsonpath='{.spec.template.spec.containers[0].image}'
520+ echo ''
521+ echo '=================================='
522+ """
523+
524+ echo ' Alpha deployment completed!'
525+ }
526+ }
527+ }
528+ }
529+ }
530+
531+ stage(' E2E Testing - Alpha Validation' ) {
532+ when {
533+ anyOf {
534+ branch ' dev'
535+ expression { return env. BRANCH_NAME ==~ / feat-.+/ }
536+ expression { return env. BRANCH_NAME ==~ / alpha-.+/ }
537+ expression { return env. BRANCH_NAME . contains(' alpha' ) }
538+ }
539+ }
540+ steps {
541+ container(' builder' ){
542+ dir(' elohim-app' ) {
543+ script {
544+ def props = loadBuildVars()
545+
546+ withBuildVars(props) {
547+ echo ' Running E2E tests against alpha'
548+ env. E2E_TESTS_RAN = ' true'
549+
550+ // Install Cypress if needed
551+ sh '''
552+ if [ ! -d "node_modules/cypress" ]; then
553+ npm install cypress @badeball/cypress-cucumber-preprocessor @cypress/browserify-preprocessor @bahmutov/cypress-esbuild-preprocessor
554+ fi
555+ '''
556+
557+ // Verify alpha is up
558+ sh '''
559+ timeout 60s bash -c 'until curl -s -o /dev/null -w "%{http_code}" https://alpha.elohim.host | grep -q "200\\ |302\\ |301"; do
560+ sleep 5
561+ done'
562+ echo "✅ Alpha site is responding"
563+ '''
564+
565+ // Run tests
566+ sh """ #!/bin/bash
567+ export CYPRESS_baseUrl=https://alpha.elohim.host
568+ export CYPRESS_ENV=alpha
569+ export CYPRESS_EXPECTED_GIT_HASH=${ GIT_COMMIT_HASH}
570+ export NO_COLOR=1
571+ export DISPLAY=:99
572+
573+ Xvfb :99 -screen 0 1024x768x24 -ac > /dev/null 2>&1 &
574+ XVFB_PID=\$ !
575+ sleep 2
576+
577+ npx cypress verify > /dev/null
578+ mkdir -p cypress/reports
579+
580+ npx cypress run \\
581+ --headless \\
582+ --browser chromium \\
583+ --spec "cypress/e2e/staging-validation.feature"
584+
585+ kill \$ XVFB_PID 2>/dev/null || true
586+ """
587+
588+ echo ' ✅ Alpha validation passed!'
589+ }
590+ }
591+ }
592+ }
593+ }
594+ post {
595+ success {
596+ echo ' ✅ E2E tests passed - alpha validation successful!'
597+ }
598+ always {
599+ dir(' elohim-app' ) {
600+ script {
601+ if (env. E2E_TESTS_RAN == ' true' ) {
602+ echo ' 📊 Publishing cucumber reports...'
603+
604+ // Publish cucumber reports
605+ if (fileExists(' cypress/reports/cucumber-report.json' )) {
606+ cucumber([
607+ reportTitle : ' E2E Test Results (Alpha)' ,
608+ fileIncludePattern : ' cucumber-report.json' ,
609+ jsonReportDirectory : ' cypress/reports' ,
610+ buildStatus : ' FAILURE' ,
611+ failedFeaturesNumber : -1 ,
612+ failedScenariosNumber : -1 ,
613+ failedStepsNumber : -1 ,
614+ skippedStepsNumber : -1 ,
615+ pendingStepsNumber : -1 ,
616+ undefinedStepsNumber : -1
617+ ])
618+ echo ' Cucumber reports published successfully'
619+ } else {
620+ echo ' No cucumber reports found to publish'
621+ }
622+ }
623+
624+ // Archive test artifacts
625+ if (env. E2E_TESTS_RAN == ' true' ) {
626+ if (fileExists(' cypress/screenshots' )) {
627+ archiveArtifacts artifacts : ' cypress/screenshots/**/*.png' , allowEmptyArchive : true
628+ }
629+ if (fileExists(' cypress/videos' )) {
630+ archiveArtifacts artifacts : ' cypress/videos/**/*.mp4' , allowEmptyArchive : true
631+ }
632+ if (fileExists(' cypress/reports/cucumber-report.json' )) {
633+ archiveArtifacts artifacts : ' cypress/reports/cucumber-report.json' , allowEmptyArchive : true
634+ }
635+ }
636+ }
637+ }
638+ }
639+ failure {
640+ echo ' ❌ E2E tests failed - alpha deployment validation unsuccessful'
641+ echo ' Check test artifacts and logs for details'
642+ }
643+ }
644+ }
645+
459646 stage(' E2E Testing - Staging Validation' ) {
647+ when {
648+ anyOf {
649+ branch ' staging'
650+ expression { return env. BRANCH_NAME ==~ / staging-.+/ }
651+ expression { return env. BRANCH_NAME ==~ / review-.+/ }
652+ }
653+ }
460654 steps {
461655 container(' builder' ){
462656 dir(' elohim-app' ) {
463657 script {
464658 def props = loadBuildVars()
465-
659+
466660 withBuildVars(props) {
467661 echo ' Running E2E tests against staging'
468662 env. E2E_TESTS_RAN = ' true'
469-
663+
470664 // Install Cypress if needed
471665 sh '''
472666 if [ ! -d "node_modules/cypress" ]; then
473667 npm install cypress @badeball/cypress-cucumber-preprocessor @cypress/browserify-preprocessor @bahmutov/cypress-esbuild-preprocessor
474668 fi
475669 '''
476-
670+
477671 // Verify staging is up
478672 sh '''
479- timeout 60s bash -c 'until curl -s -o /dev/null -w "%{http_code}" https://staging.elohim.host | grep -q "200\\ |302\\ |301"; do
673+ timeout 60s bash -c 'until curl -s -o /dev/null -w "%{http_code}" https://staging.elohim.host | grep -q "200\\ |302\\ |301"; do
480674 sleep 5
481675 done'
482676 echo "✅ Staging site is responding"
483677 '''
484-
678+
485679 // Run tests
486680 sh """ #!/bin/bash
487681 export CYPRESS_baseUrl=https://staging.elohim.host
488682 export CYPRESS_ENV=staging
489683 export CYPRESS_EXPECTED_GIT_HASH=${ GIT_COMMIT_HASH}
490684 export NO_COLOR=1
491685 export DISPLAY=:99
492-
686+
493687 Xvfb :99 -screen 0 1024x768x24 -ac > /dev/null 2>&1 &
494688 XVFB_PID=\$ !
495689 sleep 2
496-
690+
497691 npx cypress verify > /dev/null
498692 mkdir -p cypress/reports
499-
693+
500694 npx cypress run \\
501695 --headless \\
502696 --browser chromium \\
503697 --spec "cypress/e2e/staging-validation.feature"
504-
698+
505699 kill \$ XVFB_PID 2>/dev/null || true
506700 """
507-
701+
508702 echo ' ✅ Staging validation passed!'
509703 }
510704 }
0 commit comments