SonarQube/AAzure DevOps代码分析失败-找不到.scannerwork/report-task.tx



我们在SonarQube中运行由Azure DevOps:中的管道触发的自动代码质量扫描

# retrieve and build code, run unit tests etc.
- task: SonarQubePrepare@4
displayName: 'Prepare SonarQube Scan'
inputs:
SonarQube: 'SonarQube DevOps Connection'
scannerMode: 'CLI'
configMode: 'file'
- task: SonarQubeAnalyze@4
displayName: 'Run SonarQube Scan'
- task: SonarQubePublish@4
displayName: 'Publish SonarQube Scan Report'
inputs:
pollingTimeoutSec: '300'

大约一周前,所有管道的主要分析任务("Run SonarQube Scan"(开始失败,出现以下错误:

...
##[error]ERROR: Error during SonarQube Scanner execution
ERROR: Error during SonarQube Scanner execution
##[error]java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
...
##[error]Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)
Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)
...

我们没有对管道进行任何更改,所以我对是什么导致了这种更改感到困惑。

我们使用SonarQube Enterprise Edition 7.9.1版(内部版本27448((内部部署安装(和用于Azure DevOps的SonarQobe扩展4.9.0版(由SonarSource发布(。

更新25/3/20(感谢patricklu msft(:

我们使用的是带有ubuntu-16.04映像的Microsoft托管的生成代理。在调试模式下运行管道会显示以下内容:

2020-03-25T14:25:00.3694399Z 14:25:00.369 DEBUG: Report metadata written to /home/vsts/work/_temp/sonar/20200325.2/eec0f38a-913b-3db3-e1b2-71091ea5f860/report-task.txt

因此,报告元数据似乎正在写入/home/vsts/work/_temp/sonar/20200325.2/eec0f38a-913b-3db3-e1b2-71091ea5f860/report-task.txt,但SonarQube随后在/home/vsts/work/1/s/.scannerwork/report-task.txt中查找它们。看起来某个地方缺少mv操作。。。

不确定这是否是与SonarQube任务相关的问题。

根据此处的链接:

The new version (4.7.x) is looking here:
##[debug]adjustedPattern: 'C:AzureDevopsAgent2-GCS-Docker_work_tempsonar199416**report-task.txt’

看起来支持在新版本的临时文件夹中查找report-task.txt。

试着回滚你的任务版本,并检查这是否有效。

对Azure管道日志的仔细检查发现了这两个以前没有的条目:

2020-03-26T15:26:44.0989881Z INFO: Executing post-job 'Forbidden Configuration Breaker'
2020-03-26T15:26:44.0990841Z INFO: Executing post-job 'Quality Gate Breaker'

一周前,有人在没有告诉我们的情况下安装了Sonar Build Breaker插件,但我们还没有在管道中正确配置它。将其设置为跳过质量门检查(sonar.buildbreaker.skip=true(有效地绕过它(尽管这两个日志条目仍然出现(,管道再次成功运行。

2020年4月24日更新:我现在已经将Build Breaker插件升级到v2.3.1(Build 347(,这似乎已经解决了这个问题。

最新更新