mirror of
https://github.com/cna-bootcamp/phonebill.git
synced 2025-12-06 08:06:24 +00:00
Jenkins SonarQube 파이프라인 개선: 각 서비스별 개별 Quality Gate 처리
- withSonarQubeEnv wrapper를 각 서비스별로 개별 적용 - Quality Gate 확인을 서비스별로 순차 처리 - sonar.java.binaries와 sonar.coverage.jacoco.xmlReportPaths 경로 정확히 지정 - 'No previous SonarQube analysis found' 오류 해결 - 각 단계별 상세 로깅 추가
This commit is contained in:
parent
d4dcbd1dfa
commit
5b48c22ad0
@ -86,6 +86,7 @@ podTemplate(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
stage("Get Source") {
|
stage("Get Source") {
|
||||||
|
|
||||||
checkout scm
|
checkout scm
|
||||||
props = readProperties file: "deployment/cicd/config/deploy_env_vars_${environment}"
|
props = readProperties file: "deployment/cicd/config/deploy_env_vars_${environment}"
|
||||||
}
|
}
|
||||||
@ -105,27 +106,37 @@ podTemplate(
|
|||||||
echo "⏭️ Skipping SonarQube Analysis (SKIP_SONARQUBE=${params.SKIP_SONARQUBE})"
|
echo "⏭️ Skipping SonarQube Analysis (SKIP_SONARQUBE=${params.SKIP_SONARQUBE})"
|
||||||
} else {
|
} else {
|
||||||
container('gradle') {
|
container('gradle') {
|
||||||
withSonarQubeEnv('SonarQube') {
|
// 각 서비스별로 개별적으로 SonarQube 분석 및 Quality Gate 확인
|
||||||
// 각 서비스별 테스트 및 SonarQube 분석
|
|
||||||
services.each { service ->
|
services.each { service ->
|
||||||
|
withSonarQubeEnv('SonarQube') {
|
||||||
|
echo "🔍 Starting SonarQube analysis for ${service}..."
|
||||||
|
|
||||||
|
// 서비스별 테스트 및 SonarQube 분석
|
||||||
sh """
|
sh """
|
||||||
./gradlew :${service}:test :${service}:jacocoTestReport :${service}:sonar \\
|
./gradlew :${service}:test :${service}:jacocoTestReport :${service}:sonar \\
|
||||||
-Dsonar.projectKey=phonebill-${service}-dg0500 \\
|
-Dsonar.projectKey=phonebill-${service}-dg0500 \\
|
||||||
-Dsonar.projectName=phonebill-${service}-dg0500 \\
|
-Dsonar.projectName=phonebill-${service}-dg0500 \\
|
||||||
-Dsonar.java.binaries=build/classes/java/main \\
|
-Dsonar.java.binaries=${service}/build/classes/java/main \\
|
||||||
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
|
-Dsonar.coverage.jacoco.xmlReportPaths=${service}/build/reports/jacoco/test/jacocoTestReport.xml \\
|
||||||
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
|
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
echo "✅ SonarQube analysis completed for ${service}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quality Gate 확인
|
// 각 서비스별 Quality Gate 확인
|
||||||
timeout(time: 10, unit: 'MINUTES') {
|
timeout(time: 5, unit: 'MINUTES') {
|
||||||
|
echo "⏳ Waiting for Quality Gate result for ${service}..."
|
||||||
def qg = waitForQualityGate()
|
def qg = waitForQualityGate()
|
||||||
if (qg.status != 'OK') {
|
if (qg.status != 'OK') {
|
||||||
error "Pipeline aborted due to quality gate failure: ${qg.status}"
|
error "❌ Quality Gate failed for ${service}: ${qg.status}"
|
||||||
|
} else {
|
||||||
|
echo "✅ Quality Gate passed for ${service}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "🎉 All services passed SonarQube Quality Gates!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user