Hi Team,
In SonarQube do we have the REST APIs that would allow us to retrieve some kind a ‘result’ after a scan has completed.
We wanted to have a curl command that would retrieve this data from SonarQube after the scan has completed in the scanning stage of the pipeline.
Could you please help on this.
Regards,
Nagaraj
Hi @nagaraj.koppa ,
hmm there is a endpoint that you could use for this: /api/ce/task?id=$YOUR_TASK_ID
this will return a JSON Object where you can check the status of the task. you can find more information about this endpoint in your sonarqube instance : sonarqube.your-company.com/web_api
If you are using our Jenkins Plugin then there is also the waitForQualityGate
option that you could utilize
hope that helps
Hi Tobias,
Is any sample example , how can we use curl command that retrieves some data on the last scan.
We are looking for curl command.
Can you provide some details.
Regards,
Nagaraj
Hi @nagaraj.koppa ,
as documented here you will have to use http basic auth preferably with a token. Also you will need to extract the TASK_ID
from your CI run using whatever methode you like (i don’t know your tooling).
After that you can get information about the specific run like this:
curl --user $YOUR_USER_TOKEN: $SONARQUBE_FQDN/api/ce/task?id=$YOUR_TASK_ID
the answer will be a json with information about this specific task
Hi Tobias,
We are using the Jenkins, Gitlab and SonarQube.
How can we get the TASK_ID ?
Regards,
Nagaraj
The task ID is printed after the scan execution, but if you are using jenkins anyway, you really should use our jenkins plugin and the with clause that i described in my previous post. this will result in exactly what you want without the usage of curl and custom scripting