REST API for getting project last analysis date?

为君一笑 提交于 2019-11-30 03:50:18

问题


How do I get a project's last analysis time (the one you can see in the dashboard) with the REST API of SonarQube?

I am working with SonarQube 4.5.6, but if it's only available on later versions I'd still be interested in how it is done.


回答1:


You can use the Resources API : https://nemo.sonarqube.org/api/resources/index?metrics=date&format=json and look at the 'date' field to get the last analysis time.




回答2:


[EDIT] API relevant since SonarQube v6.3: api/project_analyses/search

[EDIT] Relevant API for SonarQube LTS v5.6.x: api/projects?versions=true

And since you mention later versions, since SonarQube 5.2:

api/ce/component : get the pending tasks, in-progress tasks and the last executed task of a given component (usually a project) (documentation)

P.S.: api/components/show can be used to get the component ID from the project key

P.S.2 : here's a real-life example on public SonarQube project. First get the component ID then query the component -> "submittedAt": "2016-03-07T06:04:31+0100" (slight difference with the dashboard value, due to the processing time on the scanner side)



来源:https://stackoverflow.com/questions/35847110/rest-api-for-getting-project-last-analysis-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!