// GUARDiA Mall — CI/CD Pipeline (Jenkins, 보조) // 주 배포는 Gitea webhook → deploy_server.py(9999). Jenkins는 검증/롤백 백업 경로. // 저장소 구조: backend/, frontend/ 가 루트에 위치 (단일 jar — frontend가 backend static으로 번들됨) pipeline { agent any environment { MALL_HOME = '/opt/guardia-mall' JAVA_HOME = '/usr/lib/jvm/java-21-openjdk-amd64' // 서버 JDK21 (Java17 타겟 호환 빌드) PATH = "${JAVA_HOME}/bin:${env.PATH}" } stages { stage('Checkout') { steps { checkout scm } } // frontend 먼저 빌드 → vite outDir(../backend/src/main/resources/static)에 산출 → jar에 번들 stage('Frontend Build') { steps { dir('frontend') { sh 'npm ci --silent 2>/dev/null || npm install --silent' sh 'npm run build' } } } stage('Backend Build & Test') { steps { dir('backend') { sh 'mvn clean package -q' // 테스트 포함(CryptoUtil 게이트웨이 어댑터) } } } stage('Deploy') { steps { sh ''' sudo systemctl stop guardia-mall 2>/dev/null || true sudo mkdir -p ${MALL_HOME} sudo cp backend/target/guardia-mall-*.jar ${MALL_HOME}/app.jar sudo systemctl start guardia-mall ''' } } stage('Health Check') { steps { retry(5) { sleep 8 sh 'curl -sf http://localhost:8011/actuator/health | grep -q "UP"' } } } } post { success { echo 'GUARDiA Mall 배포 성공 (포트 8011)' } failure { sh 'sudo systemctl stop guardia-mall 2>/dev/null || true' echo 'GUARDiA Mall 배포 실패 — 서비스 중지(롤백)' } } }