Sonar webhook data 'stripped' in Jenkins

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…

Hi,

Welcome to the community!

First, 7.7 has some age on it at this point. The current version is 8.2 (8.3 expected next week) and the current LTS is 7.9.3. You should upgrade to one of those versions at your earliest convenience.

That said… it seems that you’re trying to do some custom scripting/extension using the data delivered by the webhook?

 
Ann

Thx for welcome :wink:
I’m aware that Sonar version is a bit outdated but, it is out my hands. Hope that it will be upgraded soon. At any case, according to logs, Sonar is not one to blame, I can confirm that payload is successfully received.

Reason for doing this: I’m using flow with OpenALM + Jenkins + Sonar. Feedback from developers is that they would like to have QG info directly on Jenkins job page and also posted back to ALM PR review page instead of just ‘Sonar PASS/FAILED’ message.

BR
Zoran