My problem is exactly the same as GET api/project_pull_requests/list response does not contain commit sha but I can’t continue the discussion there.
Given a projectKey
and a pullRequest
I would like to get:
- The quality Gate Status
- The revision (the value
sonar.scm.revision
) where the scanner did run.
On SonarCloud:
GET /api/project_pull_requests/list?project=<key>
And then a filter in the returned JSON Array to find a correct PR works fine.
The body looks like this:
{
"key": "1",
"title": "A test PR",
"branch": "patch-1",
"base": "main",
"status": {
"qualityGateStatus": "ERROR",
"bugs": 0,
"vulnerabilities": 0,
"codeSmells": 1
},
"analysisDate": "2023-03-15T13:58:05+0100",
"url": "https://github.com/<owner>/<project>/pull/<id>",
"target": "main",
"commit": {
"sha": "789aa2365d8aed57428b91636ac6a6899c2b3a7b",
"author": {
"name": "First Last",
"login": "firstLast@github",
"avatar": "7c4c4a33a1d1c28abd249b712651df97"
},
"date": "2023-03-15T13:54:48+0100",
"message": "A test commit"
},
"contributors": [
{
"name": "First Last",
"login": "firstLast@github",
"avatar": "7c4c4a33a1d1c28abd249b712651df97"
}
]
}
On SonarQube (on prem), tested on 9.9 LTS
The same endpoint:
GET /api/project_pull_requests/list?project=<key>
And the filter to find the correct PR contains only:
{
"key": "1",
"title": "A test PR",
"branch": "patch-1",
"base": "main",
"status": {
"qualityGateStatus": "ERROR",
"bugs": 0,
"vulnerabilities": 0,
"codeSmells": 1
},
"analysisDate": "2023-03-15T13:58:05+0100",
"url": "<on prem gitlab server>/a-group/a-subgroup/a-project/merge_requests/<id>",
"target": "main"
}
I have tried this other endpoint:
GET /api/qualitygates/project_status?projectKey=<key>&pullRequest=<pr>
But this contains the gate status but not the revision:
{
"projectStatus": {
"status": "OK",
"conditions": [
{
"status": "OK",
"metricKey": "new_reliability_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "1"
},
{
"status": "OK",
"metricKey": "new_security_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "1"
},
{
"status": "OK",
"metricKey": "new_maintainability_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "1"
},
{
"status": "OK",
"metricKey": "new_security_review_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "1"
}
],
"periods": [],
"ignoredConditions": false
}
}
Even with multiple Web-API call to Sonar, I do not understand how I can access the revision information.
Any advise is highly highly appreciated…