简体   繁体   中英

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.

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"
}

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM