问题描述
我试图将声纳云集成到我的构建中。 我在 sonarcloud.io 中创建了一个免费帐户,并在构建管道中添加了必要的步骤。
当我运行管道时,出现错误
错误:SonarScanner 执行期间出错 java.lang.IllegalStateException:java.nio.file.NoSuchFileException:/home/vsts/work/1/s/bw-outputs/build-wrapper-dump.json
进程“/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.20.0/sonar-scanner/bin/sonar-scanner”失败,退出代码为 1
另外,我尝试使用 .properties 文件。
sonar.projectKey=jfzlma0838_dockersample
sonar.projectName=dockersample
sonar.projectVersion=1.0
sonar.sources=app
# The build-wrapper output dir
sonar.cfamily.build-wrapper-output=bw-outputs
# Encoding of the source files
sonar.sourceEncoding=UTF-8
解决方法
此错误的最可能原因是您没有运行构建包装器。
步骤 1. 下载 Build Wrapper:
第 2 步:解压缩它们并将它们推送到您的存储库。
步骤 3. 将他们的路径添加到环境变量 PATH
。您可以使用以下 PowerShell 脚本:
Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};$newPath";
请注意,Azure DevOps 中存储库的路径为 $(System.DefaultWorkingDirectory)
。
步骤 4. 执行 Build Wrapper。您可以点击 this document 了解详细步骤。