refactor: stage 브랜치 제거, main에서 Stage→승인→Production 배포 흐름으로 변경
- develop: 개발서버 자동 배포 (변경 없음) - main: Stage 자동 배포 → Jenkins 승인 → Production 재빌드+배포 - stage 브랜치 더 이상 사용 안함 - Next.js는 빌드 시 env 바인딩되므로 Stage/Production 별도 빌드
This commit is contained in:
40
Jenkinsfile
vendored
40
Jenkinsfile
vendored
@@ -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' }
|
||||
|
||||
Reference in New Issue
Block a user