Fail to parse entry in bootstrap index returned from sonar-scanner

Any ideas?

In a Jenkins pipeline I am running:

  • sonar-scanner version 3.3.0.1492 with -X
  • Test project om master.zip called: sonar-scanning-examples-master/sonarqube-scanner
  • RH Linux
  • Up against a 7.1 SonarQube server
  • It’s hidden behind a nginx https proxy, with trusted SAN certs.
  • SONAR_SCANNER_OPTS= -Dsonar.host.url=https://sonarserver -Xmx512m -Djavax.net.ssl.trustStore=testsonarqube.jks -Dnet.ssl.trustStorePassword=changeit

If I hit https://sonarserver/batch/index with a browser it replies: sonar-scanner-engine-shaded-7.1-all.jar|3e26d9ec2d452f29e27358939e592296

Error output:

16:57:59.767 DEBUG: keyStore is :
16:57:59.767 DEBUG: keyStore type is : jks
16:57:59.767 DEBUG: keyStore provider is :
16:57:59.767 DEBUG: init keystore
16:57:59.767 DEBUG: init keymanager of type SunX509
16:57:59.861 DEBUG: Create: /var/lib/jenkins/.sonar/cache
16:57:59.861 INFO: User cache: /var/lib/jenkins/.sonar/cache
16:57:59.862 DEBUG: Create: /var/lib/jenkins/.sonar/cache/_tmp
16:57:59.864 DEBUG: Extract sonar-scanner-api-batch in temp...
16:57:59.869 DEBUG: Get bootstrap index...
16:57:59.869 DEBUG: Download: https://aw-lx0287.deltadev.ent/batch/index
16:58:00.129 DEBUG: Get bootstrap completed
16:58:00.130 INFO: ------------------------------------------------------------------------
16:58:00.130 INFO: EXECUTION FAILURE
16:58:00.130 INFO: ------------------------------------------------------------------------
16:58:00.130 INFO: Total time: 0.498s
16:58:00.154 INFO: Final Memory: 7M/479M
16:58:00.154 INFO: ------------------------------------------------------------------------
16:58:00.155 ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:181)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:122)
at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to parse entry in bootstrap index: <!DOCTYPE html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="apple-touch-icon" href="/apple-touch-icon.png"><link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png"><link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png"><link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png"><link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png"><link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png"><link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png"><link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png"><link rel="icon" type="image/x-icon" href="/favicon.ico"><meta name="application-name" content="SonarQube"/><meta name="msapplication-TileColor" content="#FFFFFF"/><meta name="msapplication-TileImage" content="/mstile-512x512.png"/><link href="/css/main.e04508c4.css" rel="stylesheet"><title>Loading...</title></head><body><div id="content"><div class="global-loading"><i class="spinner global-loading-spinner"></i> <span class="global-loading-text">Loading...</span></div></div><script>window.baseUrl=""</script><script src="/js/vendors~main.57ecd91f.chunk.js"></script><script src="/js/main.e04508c4.js"></script></body></html>
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.parse(BootstrapIndexDownloader.java:59)
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:44)
at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
... 7 more

Hi,

This looks like an issue with your proxy. If you can, try an analysis that bypasses the proxy & you should see everything work as expected.

 
Ann

Ann - sorry to say that does not help me very much.

Another bit of information …

The issue occurs in a jenkins job, which implements a repeatable process to create and provision dockers for the nginx proxy, sq, and postgres. The job works just fine and has done for several months. The containers run and I can successfully process scans from sonar-scanner against them from other jenkins build pipelines.

The reported issues occur in a newly added build step to run an automated test of the build-started images.

I had thought that the issue occurred because the test was being run before the server had initialized. I believe I have ruled this out by putting a wait in the pipeline and hitting the server URL with curl (to simulate a browser interaction) before running the test. However that does not seem to have done the trick.

I also notice that there is another post in this forum that looks suspiciously similar that report the same issue occurring from jenkins. Issue regarding sonarqube jenkins integration

No clear resolution in the post …

I suppose the next step is to try kicking off the test in a subsequent build and see if that will run the test - not an elegant solution. I’d prefer a real fix.

Hi,

To be clear, analysis runs just fine, and the issue you’re seeing is coming from some non-analysis test of the SonarQube instance? If that’s the case, I’m not sure I can help you much.

That said, I do notice that your SONAR_SCANNER_OPTS value is a bit odd. The memory setting is perfectly normal there, although it should be right after the =, with no spaces in between. The -Dsonar.host.url key/value pair simply doesn’t belong there. Nor, I think, do the trustStore pairs. (Docs.)

 
Ann

No, the analysis, run after the docker images are build and started executing, followed by a short wait to make sure they up, followed by a “ping” from a curl to the server URL, does not run - the traceback shows the failure. However if I subsequently run the same sonar-scanner test from a command line - it works just fine.

TY. I’ll adjust the opts and retry …

Hi,

Okay, so for each project / analysis you’re spinning up a new Docker container with an independent SonarQube instance? And if so why?

If I’m understanding correctly what you’re doing, you probably don’t want to be doing a simple “ping” but probably using the api/system/health check instead.

 
Ann

No. A single stack of nginx/SQ/postgres to serve multiple scans. Done in a build process followed by an automated test. I’ll try the suggested api … more as I know more…

TY

Fixed it … seems like it was a timing issue waiting for the server to initialize …

This snippet does the trick …

HOST="sonarqube"
URL="https://${HOST}"
echo "Ping the server"
# Wait for server to initialize - 3 states - html, json red, json green
set +e
while true; do
   sleep 10
   resp=$(curl -s -u admin:admin ${URL}/api/system/health | grep 'html')
   if [ -z $resp ] ; then
     break
   fi
done
set -e
# And for real ...
while true; do
  sleep 5
  state=$(curl -s -u admin:admin ${URL}/api/system/health | jq -r  '.health')
  if [ "${state}" == 'GREEN' ] ; then
    break
  fi
done

And the execution has to be set up like this to call sonar-scanner, otherwise the certs are refused:

...
export SONAR_SCANNER_OPTS="-Xmx512m -Dsonar.verbose=true -Dsonar.host.url=${URL} -Djavax.net.ssl.trustStore=${certs} -Dnet.ssl.trustStorePassword=changeit"    
export PATH=`pwd`/scanner/sonar-scanner-${ssv}-linux/bin:$PATH:/usr/lib/jvm/java-1.8.0/bin                                                                     
# run it on a project                                                                                                                                          
(                                                                                                                                                              
    cd `pwd`/scanner/tests/sonar-scanning-examples-master/sonarqube-scanner                                                                                      
    sonar-scanner -X                                                                                                                                             
)
...