Web API: api/qualitygates/search - projects using default Quality Gate

Hello,

I want to use the web API to get a list of projects that use the default Quality Gate (SQ 7.9). Using api/qualitygates/search with the gateId of the default Quality Gate does not work, selected returns false. Seems that this API only returns explicitly assigned Quality Gates?

How can I get a list of projects that use the default Quality Gate?

Regards,
Günter

Hey Günter,

You will have to iterate through each project using GET api/qualitygates/get_by_project and parse the results from there.

For example:

http://localhost:9000/api/qualitygates/get_by_project?project=org.sonarqube%3Asonarqube-scanner

{"qualityGate":{"id":"AXk2kfnOX2R_NZrDp2_d","name":"Sonar way","default":true}}

Hi Colin,

Thanks a lot for your solution.

The thing I don’t understand is why I don’t get this result from the api/qualitygates/search API? If no explicit Quality Gate is set, it is per definition the default. Think the current behavior is a bug.

Regards,
Günter

Hey Gunter,

Projects using the default Quality Gate are not really assigned any Quality Gate explicitly…. for those projects SonarQube just looks up what the default is and use that.

Nowhere in the UI lists out the projects using the default quality gate, and therefore the web services aren’t designed to do so either.

Hi Colin,

… Nowhere in the UI lists out the projects using the default quality gate …

Yes you are right, that is the second problem. Also in the UI there is no possibility to find out which projects are using the Default Quality Gate (by the way with Default Quality Profiles it’s the same issue).

In both cases it is not very logical that I’m not able to see it. If no explicit value is assigned it’s the default. So if I’m asking “who is using this quality gate/profile?” I should get all which are using it (direct or indirect).

Regards,

Hey Günter,

In no way do I think this is an invalid question, and I think it helps your case if you discuss the use-cases for this information that are relevant to you.