This commit is contained in:
Ubuntu 2025-06-19 07:10:29 +00:00
commit 5f7585c68b

View File

@ -1,4 +1,4 @@
// smarketing-backend/smarketing-java/deployment/Jenkinsfile_ArgoCD // smarketing-backend/smarketing-java/deployment/Jenkinsfile
def PIPELINE_ID = "${env.BUILD_NUMBER}" def PIPELINE_ID = "${env.BUILD_NUMBER}"
@ -30,6 +30,7 @@ podTemplate(
def MANIFEST_REPO = 'https://github.com/won-ktds/smarketing-manifest.git' def MANIFEST_REPO = 'https://github.com/won-ktds/smarketing-manifest.git'
def MANIFEST_CREDENTIAL_ID = 'github-credentials-smarketing' def MANIFEST_CREDENTIAL_ID = 'github-credentials-smarketing'
try {
stage("Get Source") { stage("Get Source") {
checkout scm checkout scm
@ -192,14 +193,7 @@ podTemplate(
# 변경사항이 있으면 커밋 및 푸시 # 변경사항이 있으면 커밋 및 푸시
if [ -n "\$(git status --porcelain)" ]; then if [ -n "\$(git status --porcelain)" ]; then
git add . git add .
git commit -m "Update SMarketing services to ${imageTag} git commit -m "Update SMarketing services to ${imageTag} - Build ${env.BUILD_NUMBER}"
Services updated:
${services.collect { "- ${it}: ${props.registry}/${props.image_org}/${it}:${imageTag}" }.join('\n')}
Build: ${env.BUILD_NUMBER}
Commit: ${env.GIT_COMMIT}"
git push origin main git push origin main
echo "✅ Successfully updated manifest repository" echo "✅ Successfully updated manifest repository"
else else
@ -212,7 +206,6 @@ podTemplate(
} }
stage('Trigger ArgoCD Sync') { stage('Trigger ArgoCD Sync') {
steps {
script { script {
echo """ echo """
🎯 CI Pipeline 완료! 🎯 CI Pipeline 완료!
@ -230,25 +223,24 @@ podTemplate(
""" """
} }
} }
}
}
post { // 성공 시 처리
always {
container('docker') {
sh 'docker system prune -f || true'
}
sh 'rm -rf manifest-repo || true'
}
success {
echo """ echo """
✅ CI Pipeline 성공! ✅ CI Pipeline 성공!
🏷️ 새로운 이미지 태그: ${imageTag} 🏷️ 새로운 이미지 태그: ${imageTag}
🔄 ArgoCD가 자동으로 배포를 시작합니다 🔄 ArgoCD가 자동으로 배포를 시작합니다
""" """
} catch (Exception e) {
// 실패 시 처리
echo "❌ CI Pipeline 실패: ${e.getMessage()}"
throw e
} finally {
// 정리 작업 (항상 실행)
container('docker') {
sh 'docker system prune -f || true'
} }
failure { sh 'rm -rf manifest-repo || true'
echo "❌ CI Pipeline 실패!"
} }
} }
} }