Get Quality Gate status using Groovy syntax [Jenkins]

17 views
Skip to first unread message

Monta Mallek

unread,
Apr 19, 2018, 5:17:09 AM4/19/18
to SonarQube
Hi everyone,

I'm using the tool Jenkins to build my projects and I have configured SonarQube with it to analyze my source code by adding the necessary steps to the Build definition.

I want to get the Quality Gate status of a specific project using Groovy PostBuild Plugin to trigger some actions when the QG status is "WARN". Is there any possible way to obtain the QG status like that :

if(????) {
    // actions
Any idea of what can be in place of ????

Or is there a method to get the status using the QG API : 
http://192.168.1.53:9000/sonar/api/qualitygates/project_status?projectKey=
Exemple:

{"projectStatus":{"status":"WARN","conditions":[{"status":"OK","metricKey":"blocker_violations","comparator":"GT","warningThreshold":"104","errorThreshold":"109","actualValue":"95"},{"status":"OK","metricKey":"critical_violations","comparator":"GT","warningThreshold":"72","errorThreshold":"76","actualValue":"62"},{"status":"OK","metricKey":"duplicated_lines_density","comparator":"GT","warningThreshold":"23.1","errorThreshold":"24.1","actualValue":"21.6"},{"status":"OK","metricKey":"major_violations","comparator":"GT","warningThreshold":"1210","errorThreshold":"1265","actualValue":"845"},{"status":"WARN","metricKey":"minor_violations","comparator":"GT","warningThreshold":"589","errorThreshold":"616","actualValue":"612"},{"status":"OK","metricKey":"complexity","comparator":"GT","warningThreshold":"1963","errorThreshold":"2052","actualValue":"1723"},{"status":"OK","metricKey":"sqale_rating","comparator":"GT","errorThreshold":"3","actualValue":"2"}],"periods":[{"index":1,"mode":"previous_version","date":"2018-04-18T11:05:47+0200","parameter":"3.0.3"}],"ignoredConditions":false}}
Reply all
Reply to author
Forward
0 new messages