ci: update Jenkinsfile for CI/CD pipeline

This commit is contained in:
zio 2026-06-01 19:51:42 +09:00
parent d77881ce43
commit c3e7d4506a

62
Jenkinsfile vendored
View File

@ -1,32 +1,32 @@
pipeline { pipeline {
agent any agent any
environment { environment {
STATIC = '/var/www/manager' STATIC = '/var/www/manager'
NOTIFY = "${ITSM_BASE_URL}/api/messenger/webhook" NOTIFY = "${ITSM_BASE_URL}/api/messenger/webhook"
} }
options { buildDiscarder(logRotator(numToKeepStr: '5')); timeout(time: 15, unit: 'MINUTES') } options { buildDiscarder(logRotator(numToKeepStr: '5')); timeout(time: 15, unit: 'MINUTES') }
stages { stages {
stage('Checkout') { steps { checkout scm } } stage('Checkout') { steps { checkout scm } }
stage('Build') { stage('Build') {
steps { steps {
dir('frontend') { dir('frontend') {
sh 'npm ci 2>/dev/null || npm install' sh 'npm ci 2>/dev/null || npm install'
sh 'npm run build' sh 'npm run build'
} }
} }
} }
stage('Deploy') { stage('Deploy') {
when { branch 'main' } when { branch 'main' }
steps { steps {
sh """ sh """
cp -r frontend/dist/. ${STATIC}/ cp -r frontend/dist/. ${STATIC}/
systemctl restart guardia-manager 2>/dev/null || true systemctl restart guardia-manager 2>/dev/null || true
""" """
} }
} }
} }
post { post {
success { sh "curl -sf -X POST ${NOTIFY} -H 'Content-Type:application/json' -d '{\"event\":\"build_result\",\"room\":\"ops\",\"success\":true,\"result_summary\":\"✅ guardia-manager 배포 완료\"}' 2>/dev/null || true" } success { sh "curl -sf -X POST ${NOTIFY} -H 'Content-Type:application/json' -d '{\"event\":\"build_result\",\"room\":\"ops\",\"success\":true,\"result_summary\":\"✅ guardia-manager 배포 완료\"}' 2>/dev/null || true" }
failure { sh "curl -sf -X POST ${NOTIFY} -H 'Content-Type:application/json' -d '{\"event\":\"build_result\",\"room\":\"ops\",\"success\":false,\"result_summary\":\"❌ guardia-manager 빌드 실패\"}' 2>/dev/null || true" } failure { sh "curl -sf -X POST ${NOTIFY} -H 'Content-Type:application/json' -d '{\"event\":\"build_result\",\"room\":\"ops\",\"success\":false,\"result_summary\":\"❌ guardia-manager 빌드 실패\"}' 2>/dev/null || true" }
} }
} }