本文共 3640 字,大约阅读时间需要 12 分钟。
本文总结目前两种常用的生成 SonarQube 结果报告的方法,以备查阅。
适用SonarQube版本 : 5.5–7.5。
官网地址:
本插件生成 PDF 格式的 sonarqube 报告.
报告包括以下内容:
概要
静态分析
动态分析
编码问题
热点:
违规详情
子模块信息(只有在存在时生成)
SONARQUBE_HOME/extensions/plugins
目录SonarQube PDF 是一个 post-job任务. 因此,PDF 报告将在SonarQube 分析结束后生成.
配置 Skip 为“否”时生成 PDF 报告功能启用。
配置 Username 和 Password。如果出现 HTTP error: 401 或者 HTTP error: 403, msg: Forbidden,请查看该配置。
5.x版本:PDF 在仪表盘中下载,如果没有下载界面,需要在“配置控件”中添加该控件
6.x 以及 7.x 版本:因为 UI 变化无仪表盘页面,在工程中 More 菜单下查看:
生成的报告内容如下:
插件可以将代码分析从 SonarQube 服务器导出为 docx、xlsx、csv、markdown 和文本文件。
该工具可以作为 JAR 可执行文件(使用命令行)或作为 Sonarqube 插件独立使用。
特性:
官网地址:
/opt/sonarqube/extensions/plugins
,重启 sonarqube,然后点击 “More”>“CNES Report”。Cnesreport 不需要任何安装。它是一个可移植的 Java 应用程序,可以根据下面的示例复制并运行它。唯一的要求是一个最新的JRE(>=1.8)。
sonar-cnes-report.jar
复制到 sonarqube 的插件文件夹中(在 linux 上路径应该是这样的 /opt/sonarqube/extensions/plugins
)sudo service sonar restart
)使用 java -jar cnesreport.jar -h
以获取有关 cnesreport 以下帮助:
usage: java -jar cnesreport.jar [-a] [-b ] [-c] [-d ] [-e] [-h] [-l ] [-o ] [-p ] [-r ] [-s ] [-t ] [-v] [-w] [-x ]Generate editable reports for SonarQube projects. -a,--author Name of the report writer. -b,--branch Branch of the targeted project. Requires Developer Edition or sonarqube-community-branch-plugin. Default: usage of main branch. -c,--disable-conf Disable export of quality configuration used during analysis. -d,--date Date for the report. Format: yyyy-MM-dd. Default: current date. -e,--disable-spreadsheet Disable spreadsheet generation. -f,--disable-csv Disable csv generation. -h,--help Display this message. -l,--language Language of the report. Values: en_US, fr_FR. Default: en_US. -m,--disable-markdown Disable markdown generation. -n,--template-markdown Path to the report template in markdown. Default: usage of internal template. -o,--output Output path for exported resources. -p,--project SonarQube key of the targeted project. -r,--template-report Path to the report template. Default: usage of internal template. -s,--server Complete URL of the targeted SonarQube server. -t,--token SonarQube token of the SonarQube user who has permissions on the project. -v,--version Display current version. -w,--disable-report Disable report generation. -x,--template-spreadsheet Path to the spreadsheet template. Default: usage of internal template.Please report issues at https://github.com/cnescatlab/sonar-cnes-report/issues
如果正在使用 SonarQube 的安全实例,可以通过 -t 选项提供一个 SonarQube 身份验证令牌,并使用 -s 指定 SonarQube 实例的url。文本报告的内部模板将被 -r 选项所取代。
java -Xmx1024m -Xms1024m -jar sonar-cnes-report.jar -t 6bc36088524a4d06e3e07e73ba419127cd90ff04 -s http://172.16.106.188:9088/ -p projectId -r template.docx
生成的文件如下:
打开其中 word 的报告:
有关遗留版本,请在这里查看 wiki 页面 :
cnesreport \ SonarQube | 2.0.0Standalone | 2.1.0Standalone | 2.2.0Standalone + Plugin | 3.0.xStandalone + Plugin | 3.1.0Standalone + Plugin | 3.2.xStandalone + Plugin | 3.3.0Standalone + Plugin |
7.9.x (LTS) | X | X | (Standalone only) | X | X | X | X |
8.0 | - | - | - | - | - | X | X |
8.1 | - | - | - | - | - | X | X |
8.2 | - | - | - | - | - | X | X |
通过简单的实验,我发现 sonar-cnes-report
报告的数据较 Sonar PDF Report Plugin
更为正确,推荐使用前者。
转载地址:http://quifb.baihongyu.com/