无法计算SonarQube代码覆盖率,尽管在Gitlab项目中没有进行任何更改。

huangapple go评论66阅读模式
英文:

Unable to calculate sonarqube code coverage even though nothing has changed in the project on Gitlab

问题

Gitlab中的流水线包括SonarQube检查步骤。而且,这个特定的流水线会在一定的时间间隔内自动运行。尽管项目没有发生变化,但我收到了以下错误。可能的原因是什么?

INFO: 执行失败
INFO: -----------------------------------------------------------------------
INFO: 总时间:9.987秒
INFO: 最终内存:17M/360M
INFO: -----------------------------------------------------------------------
ERROR: 在执行SonarScanner期间出错
ERROR: 质量门状态:失败 - 在http://sonarqube......上查看详细信息

在链接中,总体代码覆盖率低于80%的错误。但这是不正确的,因为当我重新运行流水线时,它可以正常工作。

以下是Gitlab的YML文件:

sonarqube-check:
  stage: check
  script:
    - '& $SONAR_SCANNER_EXE begin /k:$SONAR_KEY /n:$SONAR_KEY /d:sonar.host.url=$SONAR_HOST_URL /d:sonar.login=$SONAR_TOKEN /d:sonar.cs.opencover.reportsPaths=coverage.opencover.xml /d:sonar.cs.nunit.reportsPaths=TestResult.xml /d:sonar.qualitygate.wait=true /d:sonar.qualitygate.timeout=180'
    - 'nuget restore -configfile $NUGET_CONFIG_PATH' # 恢复NuGet依赖项
    - 'msbuild -p:Configuration=Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg .$VS_SOLUTION_FILE'
    - '& $SONAR_SCANNER_EXE end /d:sonar.login=$SONAR_TOKEN'
  tags:
    - cf-aws-windows-runner
  only:
    - main
    - merge_requests
  dependencies:
    - build_job

SonarQube信息在这里
在此输入图像描述

重要的是,并不是每次都会出现这个错误,没有发生任何变化,但SonarQube有时无法计算项目的测试覆盖率。你能帮助我吗?

我并不总是遇到这个错误,没有任何变化,但有时SonarQube无法计算项目的测试覆盖率,当我重新运行流水线时,它可以正常工作。

英文:

The pipeline on the Gitlab includes the sonarqube check step. And this particular pipeline works automatically at certain time intervals. Although there was no change in the project, I got the following error. What could be the reason?

INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.987s
INFO: Final Memory: 17M/360M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: QUALITY GATE STATUS: FAILED - View details on http://sonarqube......

In the link I have  on overall code coverage is less than 80% error. But this is not correct because when I rerun the pipeline it works properly.

Here is the gitlab yml

sonarqube-check:
  stage: check
  script:
    - '& $SONAR_SCANNER_EXE begin /k:$SONAR_KEY /n:$SONAR_KEY /d:sonar.host.url=$SONAR_HOST_URL /d:sonar.login=$SONAR_TOKEN /d:sonar.cs.opencover.reportsPaths=coverage.opencover.xml /d:sonar.cs.nunit.reportsPaths=TestResult.xml /d:sonar.qualitygate.wait=true /d:sonar.qualitygate.timeout=180'
    - 'nuget restore -configfile $NUGET_CONFIG_PATH' # restore NuGet dependencies
    - 'msbuild -p:Configuration=Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg .$VS_SOLUTION_FILE'
    - '& $SONAR_SCANNER_EXE end /d:sonar.login=$SONAR_TOKEN'
  tags:
    - cf-aws-windows-runner
  only:
    - main
    - merge_requests
  dependencies:
    - build_job

And sonaqrqube info is here
enter image description here

The important point is I am not getting this error all the time, nothing changed but sonarqube can not calculate the test coverage of the project sometimes. Could you please help me?

I am not getting this error all the time, nothing changed but sonarqube can not calculate the test coverage of the project sometimes when I rerun the pipeline it works properly.

答案1

得分: 1

SonarQube不会计算覆盖率,它只会报告通过sonar.cs.opencover.reportsPaths提供给它的内容。

您应该检查coverage.opencover.xml文件是否在Gitlab运行中显示与您不期望的质量门限相同的覆盖率。

如果您想要更快的帮助,请访问https://community.sonarsource.com/ 并在那里提交您的帖子/问题,而不是在StackOverflow上。

英文:

SonarQube does not calculate coverage, it just reports what you give it via sonar.cs.opencover.reportsPaths.

You should check if coverage.opencover.xml file shows the same coverage or not between your Gitlab runs whenever the quality gate shows something you don't expect.

If you want quicker help, you should go to https://community.sonarsource.com/ and submit your thread/question there, not StackOverflow.

huangapple
  • 本文由 发表于 2023年5月24日 17:34:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76322087.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定