Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

code analysis - Access quality gate status from sonarqube api

My question:

I would like to obtain the current status of the quality gate for my projects in SonarQube via the SonarQube web api, but I do not see quality gate as an available metric in the documentation. What is the best way to access this information to include in a report?

Background:

I am using the SonarQube API to access information about project analyses. The output from the API is used to generate a weekly report. I can access the information about each project with the following SonarQube API call.

http://my-sonar-site/api/resources/index/?resource=$PROJECT_KEY&metrics=$METRIC_LIST

The metric list is populated from the SonarQube API documentation at

http://docs.sonarqube.org/display/SONAR/Metric+definitions

This gets me everything I want with the exception of the status of the quality gate.

What I've tried:

  • I have looked through the documentation for metrics at the above link, but failed to find quality gate status in that part of the api.
  • I have also looked at the quality gate API documented at http://nemo.sonarqube.org/api_documentation#api/qualitygates - but the quality gate API seems to be used for creating and managing quality gates and project associations rather than obtaining the current status of the gate on a per-project basis.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since SonarQube 5.3 you can get the Qualitygate Status using the API: http://[sonarhost]/api/qualitygates/project_status?analysesId=[ID]

Since SonarQube 5.4: http://[sonarhost]/api/qualitygates/project_status?projectKey=[key]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...