Better way to retrieve Quality Gate status on branches

Hi !

In me team, we are using Sonarqube web api to fill a dashboard with different metrics.
With Sonarqube 5.6, we have a dashboard which lists projects with quality gate in ERROR.

To achieve this we are retrieving all the projects and filter them by there name which contains the branch name.

With Sonarqube 7.x and the new branch system (which is great) I don’t know the best way to achieve the same behaviour.

The simplest way is :

  • use api/components/search to retrieve all the component
  • then use api/measures/component or api/project_analyses/search with the branch parameter to retrieve status one by one

But it will spam the Sonarqube server each time the dashboard is refreshed…

I’ve found that we can use /api/components/search_projects?filter=alert_status%20%3D%20ERROR to retrieve project with a particular status.
It’s exactly what I need :smile:
But there is no branch parameter available :worried:

Is there an other way to achieve this ?


Hi Clement,

(Sorry about the missing diacritic; I’m on a qwerty keyboard.)

Since your goal is updating a page outside of SonarQube(?) then your best bet is to use webhooks, which will be fired at the end of each analysis. The job that processes them can filter for failing status and update your dashboard as needed.