sonarqubesonarqube-scan

Check the code coverage for a project on sonar with rest api


Sonar version : 5.3

I am making this call

https://mysonar/api/resources/index?metrics=coverage&key=test-project

However , I am not getting the coverage of test-project from this call. But I am getting rest of the projects and their coverages. When I just do this

https://sonarurl.com/api/resources/index

I am able to see my test-project on the api response.

How do I drill down to a specific project and not check the other projects from the rest call to Sonar.


Solution

  • The api/resources doesn't support the key parameter. You have to specify project id by using qualifiers and resource parameters.

    This should work for you:

    https://mysonar/api/resources/index?metrics=coverage&qualifiers=TRK&resource=test-project
    

    Available values of the qualifiers parameter: