声纳 Gerrit 插件不报告结果 [英] Sonar Gerrit plugin not reporting results

查看:17
本文介绍了声纳 Gerrit 插件不报告结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们利用管道,在构建成功完成后,我们正在运行以下内容:

We utilize the pipeline and after the build completes successfully we are running the following:

bat "mvn sonar:sonar -B -s ${buildSettings} -Dsonar.analysis.mode=preview -Dsonar.skipDesign=true -Dsonar.report.export.path=sonar-report.json"

sonarToGerrit(severity: 'Major', postScore: true, category: 'Code-Review', newIssuesOnly: true, issuesScore: '0', noIssuesScore: '0', changedLinesOnly: true)

下面的构建日志显示它发现了很多问题,但要评论的问题是 0.

The below build log shows that it found a good number of issues but yet the issues to be commented is 0.

构建日志

其他帖子表明它可能找不到该报告,但我不认为是这种情况,因为它发现了许多问题.任何管道配置建议将不胜感激.

Other posts suggest that it may not be finding the report but I don't believe it's the case as it found a number of issues. Any pipeline configuration advice would be much appreciated.

我们正在使用 Sonar Gerrit 插件版本 2.2.1、Gerrit Trigger 2.27.3 和 Jenkins Enterprise 版本是 2.60.3.1.

We are using Sonar Gerrit plugin version 2.2.1, Gerrit Trigger 2.27.3 and Jenkins Enterprise version is 2.60.3.1.

推荐答案

关于您的问题的最常见情况与 SonarQube 检查整个项目这一事实有关,而不管在特定更改中进行了多少更改.创建新报告时,它会将结果与存储在其数据库中的结果(与以前在预览以外的模式中发现的问题)进行比较.因此,声纳将之前不知道的所有问题标记为新问题(如果您根本不将此信息存储在 SonarQube 中 - 所有问题都将被标记为新问题).但是 sonar-gerrit 插件只能将问题发布到受它正在验证的更改影响的文件中.因此,即使您将设置newIssuesOnly"和changedLinesOnly"设置为false",文件中不受更改影响的所有问题都将被忽略.

The most common case regarding to your question is related to the fact that SonarQube checks the whole project, regardless of amount of changes that were done in particular change. When creating a new report, it compares a result with a result that is stored to it's database (with previously found issues that were found in a mode other than preview). Thus sonar marks as new all the issues that it was not aware about before (and if you don't store this information in SonarQube at all - all the issues will be marked as new). But sonar-gerrit plugin can only post issues to the files that were affected by the change it is verifying. So, even if you set to "false" the settings "newIssuesOnly" and "changedLinesOnly", all the issues in files not affected by the change will be ignored.

很快,请检查您的声纳报告中标记为isNew"="true" 的问题是否已在您的提交中实际更改(对于 changedLinesOnly=true)或位于更改的文件中(对于 changedLinesOnly = false)正在尝试检查.

另一个可能的原因是项目配置设置.如果您的文件是子模块的一部分,您需要将子模块名称包含到项目基目录集.或者您可能想尝试使用 允许自动匹配" 功能.该功能尝试自动将 SonarQube 模块与 Gerrit 名称匹配(自 2.1 起可用).

Another possible reason is the project configuration settings. If your files are part of a submodule, you'll need to include the submodule name to project base directories set. Or you may want to try a feature "allow auto match" instead. The feature tries to match SonarQube modules to Gerrit names automatically (available since 2.1).

与您的问题无关的关于您的管道代码的建议:

Not related to your question advises regarding your pipeline code:

目前,严重性(和其他枚举值)的设置识别是区分大小写的.事实上,插件会忽略您的主要"设置,因为它无法识别它,并将其替换为默认的信息"值.

At the moment settings recognition for severity (and other enum values) is case-sensitive. In fact, the plugin ignores your "Major" setting as it cannot recognize it, and replaces it with default "INFO" value.

另一件事,我不明白为什么在设置issuesScore"= 0 和noIssuesScore"=0 时将postScore"设置为 true.为简单起见,您可以设置 postScore=false 并跳过这些设置以及类别".

Another thing, I don't see why do you set your "postScore" to true as you set "issuesScore" = 0 and "noIssuesScore"=0. You can just set postScore=false and skip these settings along with "category" for sake of simplicity.

另外,如果你使用 2.0 以上版本的插件,请注意 API 略有变化,现在使用下一个结构:

Also, if you use the version of plugin above 2.0, be aware that API has slightly changed and now uses the next structure:

sonarToGerrit (
        reviewConfig: [ 
            issueFilterConfig: [
                severity: 'MAJOR', 
                newIssuesOnly: false, 
                changedLinesOnly: false
                ], 
            noIssuesTitleTemplate: 'Your text here',
            someIssuesTitleTemplate: 'Your text here',
            issueCommentTemplate: 'Your text here'
        ]
    )

虽然您的代码也应该可以工作(插件确实支持以前的版本),但存在错误的可能性更大.

Though your code should also work (plugin does support previous versions), there is a bigger chance that there may be a bug.

这篇关于声纳 Gerrit 插件不报告结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆