SonarQube: Fail to get bootstrap index from server: Status returned by url [http://hostname:9095/sonar/batch/index] is not valid: [403]

后端 未结 7 858
广开言路
广开言路 2021-01-04 04:37

I am trying to execute following maven command from jenkins job, mvn clean install sonar:sonar -Dsonar.host.url=http://hostname:9095/sonar -Dsonar.projectKey=mavensam

相关标签:
7条回答
  • 2021-01-04 05:06

    Upgrade to solve sonar version issue.

    org.apache.maven.plugins maven-compiler-plugin 3.5.1

    0 讨论(0)
  • 2021-01-04 05:08

    Try to use sonar-maven-plugin version 3.2 in your pom.xml

    pom.xml

    <properties>
      <sonar.host.url>http://xxxxx:9000</sonar.host.url>
      <sonar.login>be2fe3y27f07db354983dfxysdsa5256</sonar.login>
      <sonar.language>java</sonar.language>
      <sonar.scm.provider>git</sonar.scm.provider>
    </properties>
    <plugin>
      <groupId>org.sonarsource.scanner.maven</groupId>
      <artifactId>sonar-maven-plugin</artifactId>
      <version>3.2</version>
    </plugin>
    

    This works for me.

    0 讨论(0)
  • 2021-01-04 05:15

    I've recently had a very similar problem For me the resolution is to do with the proxy settings, if you don't have a proxy then skip this answer.

    My command

    mvn clean sonar:sonar -Dsonar.host.url=http://192.168.56.101:9000 -Dsonar.login=admin -Dsonar.password=admin

    [INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ baselineV001-parent ---
    [INFO] User cache: /home/developer/.sonar/cache
    [ERROR] SonarQube server [http://192.168.56.101:9000] can not be reached
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary for baselineV001-parent 1.0.0-SNAPSHOT:
    
    ... skipping some info lines for brevity (its a big project)
    
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project baselineV001-parent: Unable to execute SonarQube: Fail to get bootstrap index from server: Status returned by url [http://192.168.56.101:9000/batch/index] is not valid: [503] -> [Help 1]
    

    The key part of the log being http://192.168.56.101:9000/batch/index is not valid. I can curl this url and it works.

    After a little thinking about what is different from curl, I have a proxy set in maven settings ~/.m2/settings.xml but I dont have one set for curl.

    To check if proxy is the issue I removed the proxy entry in my settings.xml and then I saw it working and communicating with my sonarqube server

    So if you have a proxy, you probably want to specify your sonarqube server as a host in the field nonProxyHosts in ~/.m2/settings.xml

      <proxies>
        <proxy>
          <id>intranet-proxy</id>
          <active>true</active>
          <protocol>http</protocol>
          <username/>
          <password/>
          <host>proxy.intra.redacted.com</host>
          <port>8080</port>
          <nonProxyHosts>localhost|192.168.56.101</nonProxyHosts>
        </proxy>
      </proxies>
    

    Also a small point about advising people to use v3.2. It might be a fix, but it shouldn't be the long term answer as v3.2 is currently 3 years old (4 years old come September 2020). I've seen in other threads the sonarsource support team says give us more information about this problem, but on a newer version of sonar-maven-plugin.

    Edit 1: Forgot to say that I could not find a change in the v3.3.0.603 of sonar-maven-plugin at https://github.com/SonarSource/sonar-scanner-maven, but it seems that versions 3.3.0.603 to current (3.7.0.1746) and probably future versions pay attention to the maven settings for proxies. You could argue it was a bug in previous versions that they didn't honor maven's proxy settings. Edit 2: typo

    0 讨论(0)
  • The issue was with sonar-maven plugin version 3.3 I tried with version 3.2 and it worked. I passed following to maven command line arguments org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar

    0 讨论(0)
  • 2021-01-04 05:22

    This issue exists in org.sonarsource.scanner.maven.sonar-maven-plugin 3.5.0 plugin as well.

    Upgrade your POM dependency to use a new Version or some earlier version like 3.2 are also stable.

    org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
    
    0 讨论(0)
  • 2021-01-04 05:28

    We had a same issue. In our case both Jenkins and SonarQube were running on the same machine behind a reverse proxy. It resolved our issue after updating sonar host URL to http://localhost:9000.

    0 讨论(0)
提交回复
热议问题