在 Azure DevOps 管道上执行项目构建器后,声纳扫描仪失败

问题描述 投票:0回答:1

上下文:我在 Azure DevOps 上有一个管道在自托管代理(部署在 kubernetes 上)上运行,并且我正在使用任务“运行代码分析”(紧接在任务“准备分析配置”之后),来自 Azure 市场上的 SonarQube 扩展

问题:在配置SonarQube for Azure DevOps之后,在运行“运行代码分析”任务时,管道会产生错误:

INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.15 Private Build (64-bit)
INFO: Linux 5.4.17-2136.304.4.1.el7uek.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Scanner configuration file: /azp/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/5.6.1/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /azp/_work/1/s/sonar-project.properties
INFO: Analyzing on SonarQube server 9.4.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=112ms
INFO: Server id: 41D5D374-AYHzDcd0-Nvlhdy2JQfz
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=40ms
INFO: Load/download plugins (done) | time=143ms
INFO: Process project properties
INFO: Process project properties (done) | time=1ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
WARN: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ClassRealm{javascript}-org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl': Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'AnalysisTempFolder' defined in org.sonar.scanner.analysis.AnalysisTempFolderProvider: Unsatisfied dependency expressed through method 'provide' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DefaultInputProject' defined in org.sonar.scanner.scan.InputProjectProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.api.batch.fs.internal.DefaultInputProject]: Factory method 'provide' threw exception; nested exception is Validation of project failed:
  o To use the property "sonar.branch.name" and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.808s
INFO: Final Memory: 16M/237M
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarScanner execution
ERROR: Validation of project failed:
  o To use the property "sonar.branch.name" and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.
ERROR: Error during SonarScanner execution
ERROR: Validation of project failed:
##[error]ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
##[error]The process '/azp/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/5.6.1/sonar-scanner/bin/sonar-scanner' failed with exit code 2
Finishing: Run Code Analysis

我进行了大量搜索,发现社区版和开发者版 SonarQube 的分支分析选项不同。

但是,我尝试执行我的天蓝色代理并从那里运行声纳扫描仪,它工作得很好!

我跑了什么:

/azp/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/5.6.1/sonar-scanner/bin/sonar-scanner -Dsonar.host.url=<our-server-url> -Dsonar.login=<sonarqube-generated-token> -Dsonar.projectKey=<the-project-key> -Dsonar.scm.disabled=true

其中的一些输出:

INFO: Scanner configuration file: /azp/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/5.6.1/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.15 Private Build (64-bit)
INFO: Linux 5.4.17-2136.304.4.1.el7uek.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Scanner configuration file: /azp/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/5.6.1/sonar-scanner/conf/sonar-scanner.properties
...
INFO: Analysis total time: 1:11.998 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:13.344s
INFO: Final Memory: 46M/237M
INFO: ------------------------------------------------------------------------

我不知道该怎么解决这个问题...

azure-devops sonarqube azure-pipelines sonarqube-scan azure-pipelines-build-task
1个回答
2
投票

解决方案与这些说明中提供的步骤相关。我所做的就是将这些行添加到 helm 值中,小心地替换版本值,然后重新安装 Sonarqube。 sonarqube 步骤现在运行没有问题。

© www.soinside.com 2019 - 2024. All rights reserved.