我有一个建筑:
report
。
该代码已经过时,存在大量静态代码分析问题。我决定通过在队列时间设置SonarQubeExclude = true构建变量来全局地抑制SQ静态代码分析。
问题是SQ分析任务失败了:
##[section]Starting: Run SQ Analysis
==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarQube server.
Version : 4.18.0
Author : sonarsource
Help : Version: 4.18.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
[command]...
SonarScanner for MSBuild 5.1
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
23:11:35.03 The exclude flag has been set so the project will not be analyzed. Project file: SomeProject.csproj
...
23:11:35.03 The exclude flag has been set so the project will not be analyzed. Project file: SomeProject2.csproj
##[error]23:11:35.046 No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
23:11:35.046 No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
23:11:35.03 The exclude flag has been set so the project will not be analyzed. Project file: SomeProject3.csproj
...
23:11:35.046 The exclude flag has been set so the project will not be analyzed. Project file: SomeProject4.csproj
23:11:35.046 Generation of the sonar-properties file failed. Unable to complete the analysis.
##[error]23:11:35.046 Post-processing failed. Exit code: 1
23:11:35.046 Post-processing failed. Exit code: 1
##[error]The process '...
##[section]Finishing: Run SQ Analysis这将中止SQ分析任务,并且不会上载覆盖报告。
我知道修复它的一种方法是创建一个没有静态代码分析规则的Quality,并配置相应的SQ项目来使用它。
我能让它工作而不触及服务器端的配置吗?我不明白为什么SonarQubeExclude最终未能完成SQ分析任务。
大致相同的YAML模板被许多构建重用--一些关闭SQ任务,一些打开它们(条件YAML),但我不能做的是将SQ准备任务放在中间--所以它要么被关闭,要么打开,然后在所有构建之前运行。
SQ的准备任务:
- task: SonarQubePrepare@4
displayName: Prepare CI SQ Analysis
inputs:
SonarQube: SonarQube
scannerMode: MSBuild
projectKey: $(SonarQubeProjectKey)
projectName: $(SonarQubeProjectName)
projectVersion: $(SonarQubeProjectVersion)
extraProperties: |
sonar.cs.vscoveragexml.reportsPaths=$(Common.TestResultsDirectory)\vstest-coverage\*.xml
sonar.cs.dotcover.reportsPaths=$(Common.TestResultsDirectory)\coverage\*.CoverageResult.html
sonar.cs.opencover.reportsPaths=$(Common.TestResultsDirectory)\coverage\*.CoverageResult.xml
sonar.cs.nunit.reportsPaths=$(Common.TestResultsDirectory)\tests\*.TestResult.xml
sonar.inclusions=**/*.cs
sonar.branch.name=$(SonarQubeSourceBranch)
sonar.scm.disabled=trueSQ分析任务:
- task: SonarQubeAnalyze@4
displayName: "Run SQ Analysis"为了清楚起见,我省略了条件。
所有的构建都发生在这两个任务之间。
是否可以完全禁止静态代码分析,只上传覆盖率报告而不更改服务器端设置?
发布于 2021-03-15 10:41:00
我不明白为什么SonarQubeExclude在最后没有完成SQ分析任务。
设置该属性可以有效地告诉扫描仪,就像MSBuild项目不存在一样,因此不会报告任何问题或覆盖率。如果您已经排除了所有的MSBuild项目,那么扫描仪会抱怨没有什么可上传的。
我可以让它工作而不触及SQ服务器端的配置吗?
没有一个支持的方法来做这件事,没有。支持的选项是上传问题和覆盖,但不能忽略问题,或者像您描述的那样创建一个没有活动规则的高质量配置文件。
关于支持对旧代码进行分析的论点是检测安全漏洞,因此至少您知道这些漏洞。创建一个只包含安全规则的有限的质量配置文件,并使用它,这可能是值得的。
https://stackoverflow.com/questions/66594663
复制相似问题