ERROR: SonarQube server [http://localhost:9000] can not be reached

ERROR: SonarQube server [http://localhost:9000] can not be reached

我 运行 Jenkins,sonarqube 每个 docker 并且我在 sonarqube docker 中安装 sonar-scanner。我在我的浏览器中检查了 sonarqube localhost:9000 是否有效 我在 jenkins 中配置了 sonarqube 和 github repo,并且我在 jenkins 中构建了项目,但我收到了错误 MSG

Started by user user
Building in workspace /bitnami/jenkins/workspace/refrigerator-manager
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/dean- 
kim/refrigerator-manager # timeout=10
Fetching upstream changes from https://github.com/dean- 
kim/refrigerator-manager
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://github.com/dean- 
kim/refrigerator-manager +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # 
timeout=10
Checking out Revision 619639b2a173a3aa58ec05c13442168f7a8e49dd 
(refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 619639b2a173a3aa58ec05c13442168f7a8e49dd
Commit message: "fix sonar-project.properties file"
 > git rev-list --no-walk 619639b2a173a3aa58ec05c13442168f7a8e49dd # 
timeout=10
[refrigerator-manager] $ /sonar-scanner-3.1.0.1141-linux/bin/sonar- 
scanner -Dsonar.host.url=http://localhost:9000 ******** - 
Dsonar.projectName=Refrigerator-manager -Dsonar.projectVersion=1.0 - 
Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=my:project - 
Dsonar.host.url=http://localhost:9000 - 
Dsonar.sources=refrigeratior_manager - 
Dsonar.projectBaseDir=/bitnami/jenkins/workspace/refrigerator-manager
INFO: Scanner configuration file: /sonar-scanner-3.1.0.1141- 
linux/conf/sonar-scanner.properties
INFO: Project root configuration file: 
/bitnami/jenkins/workspace/refrigerator-manager/sonar- 
project.properties
INFO: SonarQube Scanner 3.1.0.1141
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Linux 4.9.41-moby amd64
INFO: User cache: /home/tomcat/.sonar/cache
ERROR: SonarQube server [http://localhost:9000] can not be reached
INFO: ----------------------------------------------------------------- 
-------
INFO: EXECUTION FAILURE
INFO: ----------------------------------------------------------------- 
-------
INFO: Total time: 0.441s
INFO: Final Memory: 3M/59M
INFO: ----------------------------------------------------------------- 
-------
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to execute SonarQube
ERROR: Caused by: Fail to get bootstrap index from server
ERROR: Caused by: Failed to connect to localhost/127.0.0.1:9000
ERROR: Caused by: Connection refused (Connection refused)
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full 
debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the 
SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

这是我的 sonar-project.properties 在我的 github 存储库项目根目录中。

sonar.projectKey=my:project
sonar.projectName=Refrigerator-manager
sonar.projectVersion=1.0

sonar.sources=refrigeratior_manager

sonar.host.url=http://localhost:9000

这是我的 sonarqube jenkins 系统配置

这是我的声纳扫描仪的 jenkins 全局工具配置

这是我用于执行 sonarqube 扫描仪的 Jenkins 项目配置

我搜索了 google 几天来解决这个问题,但我找不到解决方案。

当你 运行 从 Jenkins 构建时,你的 sonarqube 扫描器 运行ning 了吗? 如果没有,它会抛出上面的消息,因为 jenkins 正在尝试监听端口 9000 但什么也没有。

我有和你一样的问题

Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?

我试试在Additional里用-X arguments.It可以看到enable full debug logging.You 可以用.

似乎如果你使用代理,Sonar 将使用你的 maven .m2/settings.xml 中的第一个,所以如果你有多个条目,只会尝试第一个。

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>
        <!-- europe proxies (main proxy first for sonar!) -->
        <proxy>
            <id>http-eu-proxy</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>web-proxy.eu.mycompany.com</host>
            <port>8080</port>
        </proxy>
        <proxy>
            <id>https-eu-proxy</id>
            <active>true</active>
            <protocol>https</protocol>
            <host>web-proxy.eu.mycompany.com</host>
            <port>8080</port>
        </proxy>

        <!-- india proxies -->
        <proxy>
            <id>http-in-proxy</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>web-proxy.in.mycompany.com</host>
            <port>8080</port>
        </proxy>
        <proxy>
            <id>https-in-proxy</id>
            <active>true</active>
            <protocol>https</protocol>
            <host>web-proxy.in.mycompany.com</host>
            <port>8080</port>
        </proxy>
  </proxies>
</settings>