How to find the current quality gate of a project

3,434 views
Skip to first unread message

Michael Rüegg

unread,
Dec 2, 2016, 5:36:31 AM12/2/16
to SonarQube, Michael Rüegg
Hi,

While I was able to find a REST endpoint to assign a quality gate to a project (api/qualitygates/select), I wasn't able to find one to get the current quality gate of a project.

Did I overlook something or is there simply no way to get the current quality gate of a project (beside getting all quality gates in the system with api/qualitygates/list and then checking each quality gate for its associated projects with api/qualitygates/search)?

Thanks,
Michael

Michel Pawlak

unread,
Dec 2, 2016, 11:07:52 AM12/2/16
to SonarQube, rueegg....@gmail.com
Hi,

If you're trying to do it in Java, you can have a lok at what I've done in my plugin (SVG Badges):


Michel

Michael Rüegg

unread,
Dec 2, 2016, 11:39:47 AM12/2/16
to Michel Pawlak, SonarQube
Hi Michel,

Thanks, but I can only use the official Sonar REST interface for this. Is there a way to find the project’s quality gate by only using this?

Best regards,
Michael

Michel Pawlak

unread,
Dec 2, 2016, 11:56:01 AM12/2/16
to SonarQube, michel...@gmail.com

Then you need to use `api/qualitygates/project_status?key=<project_key>` which uses a `key` parameter (available since 5.3) (that's what my plugin is using under the hood)


Michel

Michael Rüegg

unread,
Dec 15, 2016, 6:25:14 AM12/15/16
to SonarQube, michel...@gmail.com
Hi Michel,

Thanks for your feedback. But with

/api/qualitygates/project_status?projectKey=XXX

I will only get the status of the quality gate, but not the ID of the quality gate this project is associated with.

Any ideas how I can get the quality gate ID from a projectKey?

Best regards,
Michael

mlec...@ippon.fr

unread,
Feb 8, 2017, 12:47:30 PM2/8/17
to SonarQube, michel...@gmail.com
I have the same problem. By the way I read that it is forbidden to use Db Connection inside WS. So how get id or name of the quality gate with the current ws api ?

Thx a lot.

Max.

Michel Pawlak

unread,
Feb 9, 2017, 5:40:30 AM2/9/17
to SonarQube, michel...@gmail.com, mlec...@ippon.fr
Indeed it seems that there is no way to retrieve the quality gate id/name used by a project... nor a list of projects to why a quality gate has been applied.

In other words: I can't help you. You need to have an answer from the SonarSource guys.

Regards,

Michel

G. Ann Campbell

unread,
Feb 10, 2017, 4:21:19 PM2/10/17
to SonarQube, michel...@gmail.com, mlec...@ippon.fr
Hi guys,

This should be reachable from the Quality Gate side: https://sonarqube.com/web_api/api/qualitygates/search

If a project doesn't show up in any QG's list of projects, then it's using the default QG. 


Ann

Maxence LECOINTE

unread,
Feb 11, 2017, 8:47:08 AM2/11/17
to G. Ann Campbell, SonarQube, michel...@gmail.com
Hi Ann and Michel, thx for your answers. So Ann your idea is to ask sonarqube API a list of project for a given Qualitygate ? and then try an other qualityGate, and a other, and a other ? It is an anti-patern, no ? And by the way the "api/qualitygates/search" give back projet name, not project key ! It's not easy to find the real project we look for.   

Regards,
Max


Reply all
Reply to author
Forward
0 new messages