I’m using Jenkins DSL multibranch build paired with Sonarqube community + Community branch plugin.
So far, I was using waitForQualityGate to get Sonar’s quality gate results back in Jenkins and it was working as expected. I was checking qg.status to display Sonar status but, now I tried to include more detailed info (list of failed checks) on my job page.
Problem is that, on Jenkins side, JSON printout of waitForQualityGate is just:
{"status":"ERROR"}
When I check on Sonar side, I see that hook is executed with expected payload:
{
"serverUrl": "http://localhost:9000",
"taskId": "AXGhfNdNVsTZztVdmx-_",
"status": "SUCCESS",
"analysedAt": "2020-04-22T10:43:26+0000",
"changedAt": "2020-04-22T10:43:26+0000",
"project": {
"key": "XXXXXX",
"name": "XXXXXX",
"url": "http://localhost:9000/dashboard?id=XXXXXX"
},
"branch": {
"name": "branch_name",
"type": "SHORT",
"isMain": false,
"url": "http://localhost:9000/project/issues?branch=branch_name&id=XXXXXX&resolved=false"
},
"qualityGate": {
"name": "MY_quality_gate",
"status": "ERROR",
"conditions": [
{
"metric": "new_reliability_rating",
"operator": "GREATER_THAN",
"value": "1",
"status": "OK",
"errorThreshold": "1"
},
{
"metric": "new_security_rating",
"operator": "GREATER_THAN",
"value": "1",
"status": "OK",
"errorThreshold": "1"
},
{
"metric": "new_maintainability_rating",
"operator": "GREATER_THAN",
"value": "3",
"status": "ERROR",
"errorThreshold": "1"
},
{
"metric": "new_coverage",
"operator": "LESS_THAN",
"value": "100.0",
"status": "OK",
"errorThreshold": "90"
}
]
},
"properties": {}
}
Please note that payload have status=SUCCESS and qualityGate.status=ERROR
while, on Jenkins side, it defines status=ERROR
and no qualityGate node at all?
Within job console log I can find:
[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AXGh4vchVsTZztVdmx_J' on server 'SonarQube'
SonarQube task 'AXGh4vchVsTZztVdmx_J' status is 'SUCCESS'
SonarQube task 'AXGh4vchVsTZztVdmx_J' completed. Quality gate is 'ERROR'
I also enabled FINE log mode for SonarQubeWebHook and can confirm that payload matches with payload sent from Sonar (check on sonar side)
Versions used:
Jenkins: 2.150.1
SonarQube Scanner plugin: 2.8.1
Sonarqube: 7.7.0.23042
Thx in advance for any tips or suggestions…