From 446243910fa061d2d9c7f1bd724e2db7723196bb Mon Sep 17 00:00:00 2001 From: DEV-SERVER Date: Tue, 24 Feb 2026 13:20:48 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20stage=20=EB=B8=8C=EB=9E=9C=EC=B9=98?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0,=20main=EC=97=90=EC=84=9C=20Stage?= =?UTF-8?q?=E2=86=92=EC=8A=B9=EC=9D=B8=E2=86=92Production=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=ED=9D=90=EB=A6=84=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - develop: 개발서버 자동 배포 (변경 없음) - main: Stage 자동 배포 → Jenkins 승인 → Production 재빌드+배포 - stage 브랜치 더 이상 사용 안함 - Next.js는 빌드 시 env 바인딩되므로 Stage/Production 별도 빌드 --- Jenkinsfile | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a0789999..ef4607be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,22 +14,22 @@ pipeline { stage('Prepare Env') { steps { script { - def envFile = "/var/lib/jenkins/env-files/react/.env.${env.BRANCH_NAME}" - sh "cp ${envFile} .env.local" + if (env.BRANCH_NAME == 'main') { + sh "cp /var/lib/jenkins/env-files/react/.env.stage .env.local" + } else { + def envFile = "/var/lib/jenkins/env-files/react/.env.${env.BRANCH_NAME}" + sh "cp ${envFile} .env.local" + } } } } stage('Install') { - steps { - sh 'npm install --prefer-offline' - } + steps { sh 'npm install --prefer-offline' } } stage('Build') { - steps { - sh 'npm run build' - } + steps { sh 'npm run build' } } // ── develop → 개발서버 배포 ── @@ -53,9 +53,9 @@ pipeline { } } - // ── stage → 운영서버 Stage 배포 ── + // ── main → 운영서버 Stage 배포 ── stage('Deploy Stage') { - when { branch 'stage' } + when { branch 'main' } steps { sshagent(credentials: ['deploy-ssh-key']) { sh """ @@ -77,6 +77,26 @@ pipeline { } } + // ── 운영 배포 승인 ── + stage('Production Approval') { + when { branch 'main' } + steps { + timeout(time: 24, unit: 'HOURS') { + input message: 'Stage 확인 후 운영 배포를 진행하시겠습니까?\nStage: https://stage.sam.it.kr', + ok: '운영 배포 진행' + } + } + } + + // ── main → Production 재빌드 (운영 환경변수) ── + stage('Rebuild for Production') { + when { branch 'main' } + steps { + sh "cp /var/lib/jenkins/env-files/react/.env.main .env.local" + sh 'npm run build' + } + } + // ── main → 운영서버 Production 배포 ── stage('Deploy Production') { when { branch 'main' }