Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters in SonarQube SonarScanner.MsBuild.exe

huangapple go评论55阅读模式
英文:

Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters in SonarQube SonarScanner.MsBuild.exe

问题

我正在尝试设置一个测试环境来实验 SonarQube。到目前为止,我已经执行了以下步骤:

  • 下载并安装了 SonarQube。我可以运行它,并导航至 http://localhost:9000

  • 在 Azure DevOps 中为一个仓库创建了一个新项目。Sonar 能够连接到它,读取仓库等。

  • 下载了最新版本的 SonarScanner.MsBuild 运行器。解压并将路径添加到 %PATH% 环境变量中。

  • 在 Sonar 中,我创建了一个新的用户令牌,并将其放入了运行器文件夹中的 SonarQube.Analysis.xml

    <SonarQubeAnalysisProperties  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
      <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>
    </SonarQubeAnalysisProperties>
    
  • 回到 Sonar,我创建了一个新的本地运行。

  • 选择了 生成项目令牌 选项,然后点击下一步。

  • 然后 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
使用 .NET Framework 版本的 Scanner for MSBuild
预处理已启动。
准备工作目录...
09:15:30.629  更新构建集成目标...
09:15:30.797  未经授权: 由于无效凭据而拒绝访问。请检查身份验证参数。
09:15:30.8  预处理失败。退出代码: 1

我漏掉了什么吗?

英文:

I'm trying to setup a test environment to experiment with SonarQube. This are the steps I took so far:

  • Downloaded and installed SonarQube. I am able to run it, navigate to http://localhost:9000

  • Created a new project for a repo in Azure DevOps. Sonar is able to connect to it, read the repositories, etc.

  • Donwloaded the latest version of SonarScanner.MsBuild runner. Unzipped and put the path into the %PATH% environment variable

  • In sonar I created a new User Token and put in the SonarQube.Analysis.xml from the runner folder:

    <SonarQubeAnalysisProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">

    &lt;Property Name=&quot;sonar.host.url&quot;&gt;http://localhost:9000&lt;/Property&gt;
    &lt;Property Name=&quot;sonar.login&quot;&gt;admin&lt;/Property&gt;
    &lt;Property Name=&quot;sonar.password&quot;&gt;sonar&lt;/Property&gt;
    &lt;Property Name=&quot;sonar.token&quot;&gt;squ_7b.......601&lt;/Property&gt;
    

    </SonarQubeAnalysisProperties>

  • Back to Sonar, I created a new local run.

  • Selected the option to Generate a project token and clicked Next

  • Then Sonar is asking me to run the following command:

SonarScanner.MSBuild.exe begin /k:&quot;TEST_PROJECT-local&quot; /d:sonar.host.url=&quot;http://localhost:9000&quot; /d:sonar.token=&quot;sqp_ec60....a7e1&quot;

I can see the project token was create by Sonar. But when I run it, I get the following error:

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

What am I missing?

答案1

得分: 1

尝试删除这两行:

<Property Name="sonar.login">admin</Property>
<Property Name="sonar.password">sonar</Property>

从你的 SonarQube.Analysis.xml 文件中。

我曾经遇到相同的问题,并通过这样做解决了它。我认为问题与扫描器在存在用户名和密码时尝试使用它们进行身份验证有关,但如果已列出令牌,你应该真的只需使用它进行身份验证。

英文:

Try deleting these 2 lines

&lt;Property Name=&quot;sonar.login&quot;&gt;admin&lt;/Property&gt;
&lt;Property Name=&quot;sonar.password&quot;&gt;sonar&lt;/Property&gt;

from your SonarQube.Analysis.xml file.

I was having the same problem and was able to resolve it by doing that. I think the issue is related to the scanner attempting to use login and password when they are present, but if the token is listed you should really just use that to authenticate.

huangapple
  • 本文由 发表于 2023年6月19日 15:36:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504527.html
  • .net
  • sonar-runner
  • sonarqube

List: 如何为某个索引元素应用“where”条件? go 55
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定

  • 开发者交流平台

    本页二维码