Search code examples
sonarqubesonarqube5.3hipchatsonarqube-api

How to check quality gate status for a project using the API?


I need to trigger HipChat notification for a project as soon as quality gate fails for a project in SonarQube. Is there a REST API for checking the quality gate status of a project. I couldn't find it under api/quailty_gate or api/projects.

I am open to other approaches of triggering a hipChat notifications as well.


Solution

  • The web service api/qualitygates/project_status has been introduced in v.5.3 to be able to get the gate status of a specified analysis (see parameter analysisId, which value is output during analysis). The initial goal is to be able to "break the build".

    Version 5.4 added the parameters projectId and projectKey which are convenient when analysis is not known.

    Note that version 5.5 will allow a SonarQube plugin to directly send a notification, for example to HipChat, when an analysis is finished. See JIRA ticket SONAR-7488.