From 62e48df7856cd41c3cf188a094944d6aea6d8738 Mon Sep 17 00:00:00 2001 From: Johannes Schnatterer Date: Mon, 16 Jul 2018 11:38:04 +0200 Subject: [PATCH] Jenkins: Also waits for SonarQube quality goal status for PRs. --- Jenkinsfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f139f54906..fe68eb4af0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,11 +36,9 @@ node() { // No specific label stage('SonarQube') { - def sonarQube = new SonarQube(this, 'sonarcloud.io') - analyzeWith(mvn) - if (!sonarQube.waitForQualityGateWebhookToBeCalled()) { + if (!waitForQualityGateWebhookToBeCalled()) { currentBuild.result = 'UNSTABLE' } } @@ -97,6 +95,17 @@ void analyzeWith(Maven mvn) { } } +boolean waitForQualityGateWebhookToBeCalled() { + + timeout(time: 2, unit: 'MINUTES') { // Needed when there is no webhook for example + def qGate = waitForQualityGate() + echo "SonarQube Quality Gate status: ${qGate.status}" + if (qGate.status != 'OK') { + return false + } + } +} + String getCommitAuthorComplete() { new Sh(this).returnStdOut 'hg log --branch . --limit 1 --template "{author}"' }