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,43 +206,41 @@ podTemplate(
} }
stage('Trigger ArgoCD Sync') { stage('Trigger ArgoCD Sync') {
steps {
script { script {
echo """ echo """
🎯 CI Pipeline 완료! 🎯 CI Pipeline 완료!
📦 빌드된 이미지들: 📦 빌드된 이미지들:
${services.collect { "- ${props.registry}/${props.image_org}/${it}:${imageTag}" }.join('\n')} ${services.collect { "- ${props.registry}/${props.image_org}/${it}:${imageTag}" }.join('\n')}
🔄 ArgoCD 동작: 🔄 ArgoCD 동작:
- ArgoCD가 manifest repository 변경사항을 자동으로 감지합니다 - ArgoCD가 manifest repository 변경사항을 자동으로 감지합니다
- 각 서비스별 Application이 새로운 이미지로 동기화됩니다 - 각 서비스별 Application이 새로운 이미지로 동기화됩니다
- ArgoCD UI에서 배포 상태를 모니터링하세요 - ArgoCD UI에서 배포 상태를 모니터링하세요
🌐 ArgoCD UI: [ArgoCD 접속 URL] 🌐 ArgoCD UI: [ArgoCD 접속 URL]
📁 Manifest Repo: ${MANIFEST_REPO} 📁 Manifest Repo: ${MANIFEST_REPO}
""" """
} }
} }
}
}
post { // 성공 시 처리
always { echo """
✅ CI Pipeline 성공!
🏷️ 새로운 이미지 태그: ${imageTag}
🔄 ArgoCD가 자동으로 배포를 시작합니다
"""
} catch (Exception e) {
// 실패 시 처리
echo "❌ CI Pipeline 실패: ${e.getMessage()}"
throw e
} finally {
// 정리 작업 (항상 실행)
container('docker') { container('docker') {
sh 'docker system prune -f || true' sh 'docker system prune -f || true'
} }
sh 'rm -rf manifest-repo || true' sh 'rm -rf manifest-repo || true'
} }
success {
echo """
✅ CI Pipeline 성공!
🏷️ 새로운 이미지 태그: ${imageTag}
🔄 ArgoCD가 자동으로 배포를 시작합니다
"""
}
failure {
echo "❌ CI Pipeline 실패!"
}
} }
} }