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

Jeel picture Jeel · Mar 29, 2016 · Viewed 8.6k times · Source

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.

Answer

Michael Rueegg picture Michael Rueegg · Mar 29, 2016

You can get the quality gate status by using this REST endpoint:

/api/resources/index?includealerts=true&metrics=alert_status

which will give you an output similar to this one:

{
    "key": "alert_status",
    "data": "ERROR",
    "alert": "ERROR",
    "alert_text": "Major issues > 10, Files > 3"
}