Hey @lpcruz
Since SonarQube doesn’t keep the history of a PR (it only keeps the latest analysis results), this might be a little hard to measure.
Still, I think you might be able to use Webhooks to track the history of PRs. The webhook body contains all QG conditions.
{
"serverUrl": "http://localhost:9000",
"taskId": "3905411e-f679-472e-958f-e2d155c65b67",
"status": "SUCCESS",
"analysedAt": "2025-05-26T14:24:02+0200",
"revision": "73cecbab30d0252d5bf1b4832020dbe1388a0fe0",
"changedAt": "2025-05-26T14:24:02+0200",
"project": {
"key": "colin-sonarsource_python-flask-demo_24c71932-54a1-44de-aa0c-9c433e0bc813",
"name": "python-flask-demo",
"url": "http://localhost:9000/dashboard?id=colin-sonarsource_python-flask-demo_24c71932-54a1-44de-aa0c-9c433e0bc813"
},
"branch": {
"name": "1",
"type": "PULL_REQUEST",
"isMain": false,
"url": "http://localhost:9000/dashboard?id=colin-sonarsource_python-flask-demo_24c71932-54a1-44de-aa0c-9c433e0bc813&pullRequest=1"
},
"qualityGate": {
"name": "Sonar way w/ SCA",
"status": "OK",
"conditions": [
{
"metric": "new_coverage",
"operator": "LESS_THAN",
"status": "NO_VALUE",
"errorThreshold": "80"
},
{
"metric": "new_duplicated_lines_density",
"operator": "GREATER_THAN",
"status": "NO_VALUE",
"errorThreshold": "3"
},
{
"metric": "new_security_hotspots_reviewed",
"operator": "LESS_THAN",
"status": "NO_VALUE",
"errorThreshold": "100"
},
{
"metric": "new_violations",
"operator": "GREATER_THAN",
"value": "0",
"status": "OK",
"errorThreshold": "0"
}
]
},
"properties": {
"sonar.analysis.detectedscm": "git",
"sonar.analysis.detectedci": "undetected"
}
}
You’d have to set something up to catch those webhooks and then process the data, but it’s definitely possible.