Jenkins production 배포 환경 추가 (운영서버 배포 테스트까지만 적용)
This commit is contained in:
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
pipeline {
|
||||
agent { label 'mac-mini' }
|
||||
|
||||
environment {
|
||||
SSH_TARGET = "ubuntu@chocomae.jinaju.com"
|
||||
SSH_PORT = "22"
|
||||
REMOTE_TMP = "/tmp/chocomae-deploy"
|
||||
DEPLOY_DIR = "deploy/prod-jenkins"
|
||||
ARCHIVE = "chocomae-build-${BUILD_NUMBER}.tar.gz"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Package') {
|
||||
steps {
|
||||
sh 'chmod +x ${DEPLOY_DIR}/*.sh && ./${DEPLOY_DIR}/package.sh'
|
||||
}
|
||||
}
|
||||
stage('Confirm Production') {
|
||||
steps {
|
||||
input(
|
||||
message: "Production 서버(${env.SSH_TARGET})로 배포하시겠습니까?",
|
||||
ok: 'Deploy'
|
||||
)
|
||||
}
|
||||
}
|
||||
stage('Upload') {
|
||||
steps {
|
||||
sh '''
|
||||
ssh -p ${SSH_PORT} ${SSH_TARGET} "mkdir -p ${REMOTE_TMP}"
|
||||
scp -O -P ${SSH_PORT} ${ARCHIVE} ${DEPLOY_DIR}/remote_deploy.sh ${SSH_TARGET}:${REMOTE_TMP}/
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
sh '''
|
||||
ssh -p ${SSH_PORT} ${SSH_TARGET} \
|
||||
"bash ${REMOTE_TMP}/remote_deploy.sh ${ARCHIVE}"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'rm -fv ${ARCHIVE} || true'
|
||||
}
|
||||
success {
|
||||
echo "✓ chocomae-production 배포 성공 (build #${BUILD_NUMBER})"
|
||||
}
|
||||
failure {
|
||||
echo "✗ 배포 실패 — Deploy stage였다면 원격에서 자동 롤백됨. Console Output 확인"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user