build - 错误 : Sonar server 'http://localhost:9000'

运行以下命令时: cmd/c C:\sonar-runner-2.4\bin\sonar-runner.bat

( Sonar 运行器安装在构建机器上) 我收到以下错误:
错误: Sonar 服务器'http://localhost:9000 ' 无法到达
错误:Sonar runner 执行期间出错
错误:java.net.ConnectException:连接被拒绝:连接
错误:原因:连接被拒绝:连接

什么会导致这些错误?

你好,

这是我的 sonar-runner.properties 文件:

sonar.projectKey=NDM
sonar.projectName=NDM
sonar.projectVersion=1.0

sonar.visualstudio.solution=NDM.sln

#sonar.sourceEncoding=UTF-8
sonar.web.host:sonarqube
sonar.web.port=9000

# Enable the Visual Studio bootstrapper
sonar.visualstudio.enable=true

# Unit Test Results
sonar.cs.vstest.reportsPaths=TestResults/*.trx

# Required only when using SonarQube < 4.2
sonar.language=cs

sonar.sources=.

如您所见,我设置了 sonar.web.host:sonarqube sonar.web.port=9000 但是当我运行 sonar-runner.bat 我仍然得到
错误: Sonar 服务器'http://localhost:9000 ' 无法访问 - 为什么它仍在寻找 localhost:9000
而不是我设置的 sonarqube:9000?

我在 sonar-runner.bat 的日志中看到了以下行: INFO:工作目录:D:\sTFS\26091\Sources\NDM\Source..sonar

虽然我的解决方案位于 D:\sTFS\26091\Sources\NDM\Source\

这可能是问题吗?

谢谢, 伙计

最佳答案

如果您使用 SonarScanner CLI使用 Docker,您可能会遇到此错误,因为 SonarScanner 容器无法访问 Sonar UI 容器。

请注意,使用来自另一个容器的简单 curl 也会遇到相同的错误:

docker run --rm byrnedo/alpine-curl 127.0.0.1:9000
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused

解决方法是将 SonarScanner 容器连接到同一个 docker network您的 Sonar 实例,例如使用 --network=host:

docker run --network=host -e SONAR_HOST_URL='http://127.0.0.1:9000' --user="$(id -u):$(id -g)" -v "$PWD:/usr/src" sonarsource/sonar-scanner-cli

(该命令其他参数来源于SonarScanner CLI documentation)

关于build - 错误 : Sonar server 'http://localhost:9000' can not be reached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32097414/

相关文章:

c - C语言的sublime text 2构建系统

android - 指示 Android Gradle 脚本删除未对齐的 apk 并清理 Artif

java - 什么是 org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAI

php - 在 ubuntu 上构建 php5.3.8,得到错误 : configure: erro

.net - 有没有更好的方法将 native dll 复制到 bin 文件夹?

javascript - 通过 grunt 任务更新 json 文件中的文件引用

build - 无法打开共享对象文件

tfs - 等待可用代理/等待请求代理

android - 使用-sdk :minSdkVersion 15 cannot be small

objective-c - 显示应用的构建日期