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

后端 未结 7 861
广开言路
广开言路 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条回答
  •  -上瘾入骨i
    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

      
        
          intranet-proxy
          true
          http
          
          
          proxy.intra.redacted.com
          8080
          localhost|192.168.56.101
        
      
    

    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

提交回复
热议问题