我正在尝试设置一个测试环境来测试SonarQube。这是我到目前为止采取的步骤:
- 已下载并安装SonarQube。我可以运行它,导航到http://localhost:9000
- 在Azure DevOps中为存储库创建了一个新项目。声纳能够连接到它,读取存储库等。
- 下载最新版本的SonarScanner.MsBuild runner。解压缩并将路径放入%PATH%环境变量中
- 在sonar中,我创建了一个新的User Token,并从runner文件夹中放入
SonarQube.Analysis.xml
:
<Property Name="sonar.host.url">http://localhost:9000</Property>
<Property Name="sonar.login">admin</Property>
<Property Name="sonar.password">sonar</Property>
<Property Name="sonar.token">squ_7b.......601</Property>
- 回到声纳,我创建了一个新的本地运行。
- 选择
Generate a project token
选项并单击Next - 然后Sonar要求我运行以下命令:
SonarScanner.MSBuild.exe begin /k:"TEST_PROJECT-local" /d:sonar.host.url="http://localhost:9000" /d:sonar.token="sqp_ec60....a7e1"
我可以看到项目令牌是由Sonar创建的。但是当我运行它时,我得到以下错误:
SonarScanner for MSBuild 5.13
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
09:15:30.629 Updating build integration targets...
09:15:30.797 Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters.
09:15:30.8 Pre-processing failed. Exit code: 1
我错过了什么?
2条答案
按热度按时间xwbd5t1u1#
尝试删除这两行
从你的
SonarQube.Analysis.xml
文件。我也遇到了同样的问题,并通过这样做来解决它。我认为这个问题与扫描仪试图使用登录名和密码有关,但如果列出了令牌,您真的应该使用它来进行身份验证。
a5g8bdjr2#
我遇到了类似的问题,在日志中看到了以下内容:
和
并在wireshark跟踪中看到以下内容:
根本原因是Jenkins“工具”没有更新。我能够删除工具,然后它们自动重新安装到最新版本。由于此Jenkins安装在Windows上运行,因此我们删除了此文件夹:C:\Program Files(x86)\Jenkins\Tools\哈德逊.plugins.sonar. MsBuildSQRunner安装
参考:https://www.jenkins.io/doc/book/managing/tools/
https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/ci-integration/jenkins-integration/
https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/jenkins-extension-sonarqube/