【问题标题】:401 Unauthorized error analyzing with TFS 2015 and SonarQube 5.6.1使用 TFS 2015 和 SonarQube 5.6.1 进行 401 未经授权的错误分析
【发布时间】:2017-01-15 15:58:56
【问题描述】:

我们正在使用本地 TFS 2015 Update 2 服务器,使用 TFS 版本控制。目前我们在我们的主要分析服务器上运行 SonarQube 5.5,并且每天都在执行分析,没有问题。我们没有在 SonarQube 服务器上使用 LDAP,并且每个人组都有权执行分析。

但是,我将我的测试服务器升级到 SonarQube 5.6.1,以准备更新的 FXCop 规则以及正确的规则分类(错误、漏洞等)。但是,当我尝试运行分析时,“从 SonarQube 获取质量配置文件”任务失败并出现 (401) Unauthorized 错误。我在下面有该任务的控制台输出。

我能够找到对版本 5.6 的更改。这是导致我的授权问题的原因吗? https://jira.sonarsource.com/browse/SONAR-7640

当我查看自动生成的 SonarQube.Analysis.xml 文件时,sonar.host.url、sonar.login 和 sonar.password 条目是正确的。它在文件中的用户是 sonarqube 中的管理员,并且有权执行分析。

我也在 github 上遇到过这个问题。 https://github.com/Microsoft/vsts-tasks/issues/1851

向 VSTS 添加了一个新选项,以解决声纳因 401 Unauthorized 错误而失败的问题。但是,这似乎是分析过程结束时的问题,因为它无法创建摘要报告。

如果我使用我的测试服务器,并将正在运行的 Windows 服务切换回我的 SonarQube 5.5 副本,它将在没有任何授权错误的情况下工作。

sonarqube windows 服务和 TFS 构建代理作为我的测试机器上的管理员和 TFS 管理员用户运行。

失败的任务输出:

Executing the powershell script: D:\Agent\tasks\SonarQubePreBuild\1.0.34\SonarQubePreBuild.ps1
SonarQube Scanner for MSBuild 1.1
Default properties file was found at D:\Agent\tasks\SonarQubePreBuild\1.0.34\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Loading analysis properties from D:\Agent\tasks\SonarQubePreBuild\1.0.34\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
SonarQube Scanner for MSBuild Begin Step 2.1
Loading analysis properties from D:\Agent\tasks\SonarQubePreBuild\1.0.34\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Updating build integration targets...
Fetching analysis configuration settings...
Unhandled Exception: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
  at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
  at System.Net.WebClient.DownloadString(Uri address)
  at System.Net.WebClient.DownloadString(String address)
  at SonarQube.TeamBuild.PreProcessor.WebClientDownloader.Download(String url)
  at SonarQube.TeamBuild.PreProcessor.SonarWebService.GetProperties(String projectKey, String projectBranch)
  at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, IDictionary`2& serverSettings, AnalyzerSettings& analyzerSettings)
  at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs args)
  at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.Execute(String[] args)
  at SonarQube.TeamBuild.PreProcessor.Program.Main(String[] args)
Pre-processing succeeded.
System.Exception: Unexpected exit code received from batch file: 255
  at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeBatchScriptCmdlet.ProcessRecord()
  at System.Management.Automation.CommandProcessor.ProcessRecord()

【问题讨论】:

标签: .net sonarqube


【解决方案1】:

我可以通过在我的构建代理服务上删除用户并再次添加它来完成这项工作,但要确保该服务的用户 ID 都是小写字母。老实说,这就是我所做的一切,现在它正在工作。

【讨论】:

    猜你喜欢
    • 2017-06-15
    • 1970-01-01
    • 2017-10-24
    • 1970-01-01
    • 2011-09-14
    • 2015-04-19
    • 1970-01-01
    • 1970-01-01
    • 2017-12-20
    相关资源
    最近更新 更多