Fail to get bootstrap index from server: SonarQube error

You might have come across this error “Fail to get bootstrap index from server” while running SonarQube analysis. For this blog post we will discuss this error as it occurs in Jenkins while executing a job which includes Sonar analysis. You might come across this error in SonarQube in a different setup, however you might still find it useful for troubleshooting.

Overview: SonarQube and Jenkins

SonarQube is one of the popular tools for automated code reviews. It is widely used for code inspection in a Continuous integration cycle.

Jenkins as we know is an orchestration server. It is especially helpful in orchestrating DevOps life cycle. It has numerous plugins which can be installed to integrate with various other tools for running continuous integration cycles. Jenkins server can also work as a hub for a complete continuous delivery.

SonarQube integrates easily with Jenkins server via plugins available for Jenkins.

👉 You can refer to the link mentioned below to understand how to configure SonarQube analysis on Jenkins server SonarQube integration with Jenkins Pipeline. Configuration of Jenkins server for SonarQube integration is out of scope for this article.

👉 To read other posts regarding SonarQube Click here

Scenario: SonarQube and Jenkins integration

Now let us go through a scenario with a continuous integration project on Jenkins where we have stages for Compile, Code Review, Quality Gate, Build and Deploy.

We have 2 stages where Jenkins pipeline will integrate with SonarQube for execution. First is the Code review stage. Once the code is successfully compiled, Code Review will be performed using Sonar Scanner plugin in Jenkins. The next stage i.e. Quality Gate will return either Pass or Fail based on the report received from SonarQube server. The result for Quality Gate will determine whether the execution will move on to the next stage of the CI lifecycle or return a failure.

In order to perform SonarQube analysis, we typically use the sonar scanner plugin which is configured in Jenkins. Then we need to configure the URL and authentication token for SonarQube. As a best practice, these values are configured in the “Configure System” section in “Manage Jenkins” under Server URL and Server authentication token sections, respectively, as shown below.

Configure System

During execution, Jenkins picks up these configured URL and authentication token in order to perform code analysis. Once the analysis is successful, the Jenkins job will move on to the next stage which is quality gate stage.

Why does this error occur

As we are now acquainted with how SonarQube and Jenkins work together to perform Code Review, let us discuss the reasons for the error “Fail to get bootstrap index from server”.

As we have discussed, we need to configure SonarQube URL and authentication token in Jenkins in order to perform SonarQube analysis. The main reason why this error occurs is that SonarQube is not accessible from Jenkins with the SonarQube URL configured in Jenkins. This could be due to various reasons.

Here we will discuss few possible reasons why this error can occur for a SonarQube server installed on a separate system or a virtual machine. The second part of the error will generally provide details regarding the error.

SonarQube URL provided in Jenkins is incorrect:
Error ReasonIn order to execute the SonarQube code analysis from Jenkins server, we need to provide SonarQube URL and credentials. We will typically configure these in the “Configure System” section in Jenkins. First step is to double check whether the URL provided to access SonarQube server is correct.
Verify Error ReasonIt is best to check whether the SonarQube URL configured in Jenkins is reachable via a browser. This will make it clear whether the SonarQube server is accessible via the URL and port number provided in Jenkins
Error DetailThe error in this case, where SonarQube URL is incorrect, will typically be followed by an error relating to connectivity eg Connection refused.

Unable to reach because required network ports are not open:
Error ReasonYour SonarQube server might be unreachable as it might be behind a firewall and the port on which it is being accessed (default being port 9000) is not open. Or you might be using a proxy server, so the proxy settings need to be checked. Or you might be using a cloud service provider for the SonarQube server, and the inbound ports to access SonarQube server have not been opened. In all the above cases one thing that is in common is that your SonarQube server is currently not reachable from your Jenkins server.
Verify Error ReasonSimilar to the above issue, you should confirm whether you are able to access the URL from the Jenkins server.
Error DetailThe error in this case will typically be followed by an error relating to time out eg Connection timed out.

Formation of SonarQube server URL is incorrect:
Error ReasonThis is different from the first point of incorrect URL. Here we will check the formation of the URL.
Verify Error ReasonCheck for any extra character, a slash or a space in the url. For instance, there shouldn’t be a trailing slash and a space or just a trailing space in the URL. For instance if the URL for your SonarQube server is “http://sonarserver:9000” , then it should not be mentioned as “http://sonarserver:9000 ” or “http://sonarserver:9000/ “. These URLs might even open correctly in the browser, however they will lead to exception when accessed via Jenkins.
Error DetailThe error in this case will typically be followed by an error relating to parsing url or an invalid port no.

Conclusion

In this blog post we have discussed few ways to troubleshoot the error “Fail to get bootstrap index from server”. If you are running a SonarQube analysis from Jenkins server and facing this error, then you can check the above mentioned areas for troubleshooting.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *