使用 Jenkins SonarQube 插件的 FxCop 分析?

FxCop analysis using Jenkins SonarQube plugin?

我正在尝试获取 Jenkins 构建中 .NET 项目的 FxCop 分析(调用独立 SonarQube 分析)。

配置如下所示:

主要问题是当我在 SonarQube 中启用 FxCop 规则时出现错误:

java.lang.IllegalArgumentException: The property "sonar.cs.fxcop.assembly" must be set and the project must have been built to execute FxCop rules. This property can be automatically set by the Analysis Bootstrapper for Visual Studio Projects plugin, see: http://docs.codehaus.org/x/TAA1Dg.If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".

但是,如果我在 sonar-[ 中明确设置 sonar.cs.fxcop.assembly =53=] 指向一个程序集 (.dll) 我得到了那个程序集的分析,但是该项目有多个程序集,我想要 FxCop 分析。 即使可以将程序集列表设置为参数(是吗?)这也不是 elegant/generic 解决方案并且模式不是可接受的值。

我知道 MSBuild SonarQube Runner 可以解决这个问题(不需要设置 sonar.cs.fxcop.assembly),但它看起来不太适合 Jenkins 插件(在 SonarQube Runner 安装下),因为只允许 sonar-runner 安装。

有什么方法可以让 FxCop 使用 Jenkins 插件和声纳运行器工作而无需设置 sonar.cs.fxcop.assembly 属性?

确实,应该使用 MSBuild SonarQube Runner 分析 MSBuild 项目,目前在 Jenkins 中还没有专门的构建步骤:您可以使用 Execute Windows batch command 步骤来执行 MSBuild.SonarQube.Runner.exe begin ...MSBuild.SonarQube.Runner.exe end 在调用 msbuild 之间。

随着即将发布的 Jenkins SonarQube 插件版本 2.3,将有两个专门的构建步骤,一个用于 MSBuild SonarQube Runner 的开始调用,另一个用于结束调用。参见 https://jira.sonarsource.com/browse/SONARJNKNS-219

您应该使用sonar-runner,也不应该Invoke Standalone SonarQube Analysis Jenkins构建步骤(它只是调用sonar-runner)来分析.NET项目: MSBuild SonarQube Runner 是正确的选择。