Klocwork Get the amount of issues in a provided build number

拥有回忆 提交于 2019-12-08 04:41:20

问题


How can i get the number issues of a specified build number in klocwork insights 10.0, i'll need to use this in a bash script.


回答1:


Klocwork has a WebAPI which you can use to query this type of information from a bash script, for example with curl. API documentation is also provided on your Klocwork server at http://klocwork_server_host:port/review/api, for example http://localhost:8080/review/api.

The query:

curl --data "action=search&user=my_account&project=my_project&query=build:build_1 status:Analyze state:New,Existing&ltoken=xxxx" http://localhost:8080/review/api

will return a list of all open (state New and Existing), non-cited (status Analyze) issues found in a build named build_1 of project my_project.

For a list of the keywords you can use in the query string with the search action, see Searching in Klocwork Review.

If you want just a summary of the number of defects instead of getting the whole list, you can use the report action:

curl --data "action=report&user=my_account&project=my_project&build=build_1&x=Category&y=Component&filterQuery=status:Analyze state:New,Existing&ltoken=xxxx" http://localhost:8080/review/api

which returns back a summary of the number of defects by checker category (taxonomy) and component. Sample output is below:

{"rows":[{"id":1,"name":"C and C++"},{"id":3,"name":"MISRA C"},{"id":4,"name":"MISRA C++"}],"columns":[{"id":5,"name":"System Model"}],"data":[[122],[354],[890]],"warnings":[]}

You can modify the x and y axis parameters to produce different breakdowns of the issues, for example by Severity and State instead:

curl --data "action=report&user=my_account&project=my_project&build=build_3&x=Severity&y=State&filterQuery=state:New,Existing,Fixed&ltoken=xxxx" http://localhost:8080/review/api

output:

{"rows":[{"id":1,"name":"Critical"},{"id":2,"name":"Error"},{"id":3,"name":"Warning"},{"id":4,"name":"Review"}],"columns":[{"id":-1,"name":"Existing"},{"id":-1,"name":"Fixed"},{"id":-1,"name":"New"}],"data":[[10,5,2],[20,6,1],[45,11,3],[1112,78,23]],"warnings":[]}

The WebAPI cookbook documentation has an example of using python with the report action and processing and formatting the response.

EDITED: Fix typos in examples: "&build:build_id" to "&build=build_id"



来源:https://stackoverflow.com/questions/25667465/klocwork-get-the-amount-of-issues-in-a-provided-build-number

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