Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
764 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 Answer

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]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...