I am encountering an issue while attempting to execute a SonarScanner analysis using Maven. The error message suggests that the SonarQube server cannot be reached, resulting in a build failure.
[ERROR] SonarQube server [https:private.com] can not be reached
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project feature-audit: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target → [Help 1]
Here is what I done in my configuration:
Settings.xml
It appears that the HTTPS certificate being used is either self-signed or not recognized by Java’s trusted authorities. To resolve this issue, follow these general instructions: Self-signed certificate on scanner side | SonarQube Docs
Hello there,
Managed to use the Run the keytool command:
keytool -import -trustcacerts -alias sonarqube -file “C:\Program Files\Java\jdk-17\lib\security\sonarqubecertifcate.crt” -keystore “C:\Program Files\Java\jdk-17\lib\security\cacerts”
and this imported the certificate to be added to the Java keystore. However, I get this error when I deploy my application.
[INFO] --- sonar-maven-plugin:3.9.1.2184:sonar (default-cli) @ application---
[INFO] User cache: /root/.sonar/cache
[ERROR] SonarQube server [https://private.com] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.017 s
[INFO] Finished at: 2024-04-02T02:51:29Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project feature-audit: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
While I test it locally using this command: mvn clean verify sonar:sonar -Dsonar.host.url=https://private.com -Dsonar.login=token
I get this error, meanwhile I verified my username and password is correct.
[INFO] --- sonar:3.9.1.2184:sonar (default-cli) @ feature-audit ---
[INFO] User cache: C:\Users\user\.sonar\cache
[INFO] SonarQube version: 9.9.2.77730
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/user/.sonar/cache/e541368ef78a2598e2b/sonar-scanner-engine-shaded-9.9.2.77730-all.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/user/.sonar/cache/3b0b21c24d8289cc240/scanner-enterprise-9.9.2.77730-all.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[INFO] Load global settings
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:13 min
[INFO] Finished at: 2024-04-01T23:05:25-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project feature-audit: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException