I am using SonarQube Community Edition Version 7.9.1 (build 27448). I am trying to write ETL scripts to extract project data weekly. After referring to API documentation, I came up with api/measures/search_history API. But, it seems like I have to aggregate keys to both the tag and the timestamp. Is there a way to get aggregated data at a given date? Because this API sends us values for the dates when the analysis were done. I need the analysis at a given date. Is there a API for that? If this API is the one I should use, what is the aggregation method over timestamp?
All what you say is correct. You have to reconcile analysis dates returned by the API and the SCM tags. The reason is that SonarQube does not know what SCM tag is analyzed for a given analysis, it only knows when the analysis took place. For instance you may checkout a very old tag and analyze today.
If you want to deterministically know which tag correspond to which analysis, you may:
- use the sonar.projectVersion scanning parameter to pass the SCM tag
- After each analysis, use the
api/project_analyses/create_event API to store the tag as metadata associated to a particular analysis.
– You can also do that retroactively on past analysis and
– You can do that interactively from the UI. Browse to a project, then Activity tab, then on the left pane, you can click on the gear icon and “Add custom event”
The tag metadata is then attached to a particular analysis. See below
Note that for the future scans, once your weekly script is in place, you may not need to use
api/measures/search_history but rather
api/measures/component which will return the data of the most recent scan. If you already know the tag of the most recent scan, you would have not reconciliation to do
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.