stage('Analyze static code') { steps { echo 'Analyzing code...' withMaven(maven: 'Maven', mavenSettingsConfig: '<settings id>') { withSonarQubeEnv('SonarQube') { sh 'mvn sonar:sonar' } } } } stage('Check Quality Gate') { steps { echo 'Checking quality gate...' script { timeout(time: 1, unit: 'HOURS') { def qg = waitForQualityGate() if (qg.status != 'OK') { error "Pipeline aborted due to quality gate failure: ${qg.status}" } } } } }
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://<sonarqube-server>/api/ce/task?id=AV4t4NQb-rNsRjK6-Iov
[INFO] Task total time: 4.397 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[...........]
Checking status of SonarQube task 'AV4t4NQb-rNsRjK6-Iov' on server 'SonarQube'
SonarQube task 'AV4t4NQb-rNsRjK6-Iov' status is 'PENDING'
Cancelling nested steps due to timeout
Timeout has been exceeded
Finished: ABORTED
{"task":{"organization":"default-organization","id":"AV4t4NQb-rNsRjK6-Iov","type":"REPORT","componentId":"AV4ZfNAW-rNsRjK6-IoT","componentKey":"<componentKey>","componentName":"<project>","componentQualifier":"TRK","analysisId":"AV4t4NhxuRG-2GpIV2PS","status":"SUCCESS","submittedAt":"2017-08-29T12:04:22+0000","startedAt":"2017-08-29T12:04:23+0000","executedAt":"2017-08-29T12:04:24+0000","executionTimeMs":448,"logs":false,"hasScannerContext":true}}