Hi, after analyzing a maven project with sonar plugin I’d like to retreive some metrics (like the number of vulnerabilities and bugs) to decide what to do.
I know the projectKey and the ceTaskId for the current analyzis
I can make an API call to API
/api/ce/task?id=my_task_id to get more meta data (ex. “id”, “componentId”, “componentKey”, “componentName”, “analysisId”, “submittedAt”, “startedAt”, “executedAt” …)
But I can’t find an API to get the metrics related to my analyzis
I looked at theses APIs
But none of them does provide a mapping with my current analysis meta data
I don’t want to take the last one in the history to be sure i’m getting the rignt one in case of multiple branches analysis
I don’t want to use quality profile in this case
I’m using Sonarqube CE v7.7
Welcome to the community!
In fact, I don’t think these things (analyses and historical measure values) are correlated in the system. You can search measure history (
api/measures/search_history) by date, but not by analysis id. However, you can get the Quality Gate status of each analysis on file - including the metrics tested by the QG and their values for that analysis - with
api/qualitygates/project_status (you pass in the
analysisId). So… you can either add all the
analyses metrics of interest to your QG - an admittedly kludgy solution - or be content with a date-based lookup. Note that you should be able to differentiate between branches with the
branch parameter, which is currently marked
And would you mind sharing why you need to retrieve these values?
/qualitygates/project_status would help me to acheive my goal.
I just want to take some further actions depending on reliability rating & security rating…
Thanks for your help
I want to get quality gate status of specific version.
I used api/project_analyses/search?project=Project&category=VERSION to get version number.
But i don’t know how to get analysisId. Can i get the analysisId by the date (from the API above i can gate date) . Or is there an easier solution.
In general, the best thing to do is use the UI to navigate to the data you want and use your browser’s developer tools to ‘eavesdrop’ on which web services were used to get that data. However, in this case, it’s not so obvious, so I’ve done a little detective work for you. Start with
api/project_analysis-search to find the analysis with the version of interest. Pull its
key value and pass that in as the