Jenkins: Also waits for SonarQube quality goal status for PRs.

This commit is contained in:
Johannes Schnatterer
2018-07-16 11:38:04 +02:00
parent 64b86ad1b6
commit 62e48df785

15
Jenkinsfile vendored
View File

@@ -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}"'
}