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:
root
2026-08-21 15:40:05 +02:00
parent 9b631f527c
commit 3188c88737

27
platform/Jenkinsfile vendored
View File

@@ -35,15 +35,24 @@ pipeline {
stage('SonarQube Analysis') { stage('SonarQube Analysis') {
steps { steps {
container('sonar-scanner') { container('sonar-scanner') {
withSonarQubeEnv('sonarqube') { // Analysis quality, not a deploy gate: SonarQube being
script { // unreachable (moved server, migration in progress,
def scannerHome = tool 'sonar-scanner' // temporary outage) shouldn't block shipping an
sh """ // otherwise-good build. catchError marks the build
${scannerHome}/bin/sonar-scanner \ // UNSTABLE (visible in the UI, doesn't need separate
-Dsonar.projectKey=management-platform \ // watching) and lets the pipeline continue to Deploy
-Dsonar.sources=platform \ // instead of failing the whole run.
-Dsonar.python.version=3 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
"""
}
} }
} }
} }