我正在 GitHub 中使用 SonarScanner 执行 Sonar -
dotnet tool install --global dotnet-sonarscanner --version 5.2.2
- 它正在提供结果。
SonarQube:社区版本 7.9.4
dotnet-SonarScanner:4.10.0 / 5.2.2(两者都尝试过,之前使用的是 4.10.0)
我用来执行声纳的 shell 脚本如下:
PowerShell 脚本
dotnet sonarscanner begin /key:$projectKey `
/d:sonar.log.level="DEBUG" `
/v:"$(gitversion /nofetch /showvariable AssemblySemVer)" `
/d:sonar.links.scm=$repository `
/d:sonar.scm.provider="git" `
/d:sonar.scm.revision="$(git rev-parse HEAD)" `
/d:sonar.buildString="$(gitversion /nofetch /showvariable NuGetVersion)" `
/d:sonar.host.url="https://ccq.svc.myorg.com" `
/d:sonar.login=$token `
/d:sonar.cs.opencover.reportsPaths="$pwd\CodeCoverageReports\CoverageReport.xml" `
/d:sonar.cs.xunittest.reportsPaths="$pwd\TestResults\TestResults.xml"
& $msbuild $solutionName /p:Configuration=Release /t:Build -maxcpucount:1 /consoleloggerparameters:NoSummary
dotnet sonarscanner end "/d:sonar.login=$token"
但是,当在 SonarQube 中更新结果时,它不会分析
C#
文件,而是仅分析 XML
和 JS
文件。
我在 SonarQube > Project > Aministration > General Settings 中进行了交叉检查,并且没有排除任何文件。
你能分享一下我在这里缺少什么吗?
您在线出现错误:
gitversion /nofetch /showvariable NuGetVersion
没有这样的可执行文件,可能是:
gitversion
正确的行是:
git version /nofetch /showvariable NuGetVersion
产生这样的字符串:
git version 2.42.0.windows.2
我认为,如果 SonarQube 运行这个字符串,它肯定会构建失败,因为它不会在命令行中找到请求的命令..
另外,尝试运行
command -v gitversion
来查看系统上是否存在此命令