Make SonarQube analysis non-blocking in the pipeline
Prompted by migrating SonarQube to k8s mid-session, which briefly broke Jenkins' connectivity to it (server URL config points at a fixed IP:port that had to move). That's exactly the kind of outage this stage shouldn't be able to turn into a failed deploy: analysis quality isn't a deploy gate the way the build/Sonar-unrelated stages are. Wrapped in catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') — if SonarQube is unreachable for any reason, the stage fails visibly (shows red in the stage view) and the build is marked UNSTABLE (not hidden), but the pipeline continues to Deploy instead of stopping there.
This commit is contained in:
27
platform/Jenkinsfile
vendored
27
platform/Jenkinsfile
vendored
@@ -35,15 +35,24 @@ pipeline {
|
||||
stage('SonarQube Analysis') {
|
||||
steps {
|
||||
container('sonar-scanner') {
|
||||
withSonarQubeEnv('sonarqube') {
|
||||
script {
|
||||
def scannerHome = tool 'sonar-scanner'
|
||||
sh """
|
||||
${scannerHome}/bin/sonar-scanner \
|
||||
-Dsonar.projectKey=management-platform \
|
||||
-Dsonar.sources=platform \
|
||||
-Dsonar.python.version=3
|
||||
"""
|
||||
// Analysis quality, not a deploy gate: SonarQube being
|
||||
// unreachable (moved server, migration in progress,
|
||||
// temporary outage) shouldn't block shipping an
|
||||
// otherwise-good build. catchError marks the build
|
||||
// UNSTABLE (visible in the UI, doesn't need separate
|
||||
// watching) and lets the pipeline continue to Deploy
|
||||
// instead of failing the whole run.
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
withSonarQubeEnv('sonarqube') {
|
||||
script {
|
||||
def scannerHome = tool 'sonar-scanner'
|
||||
sh """
|
||||
${scannerHome}/bin/sonar-scanner \
|
||||
-Dsonar.projectKey=management-platform \
|
||||
-Dsonar.sources=platform \
|
||||
-Dsonar.python.version=3
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user