org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube


(Patrick Delaney) #1

We are using the SonarQube plugin 3.1.0 for TFS 2015. It has been working fine for months. We were running with an http:// URL not https: … This week we have to switch to https. I changed the URL in the plugin from http://xxxx.xxxxx.xxxx:8999/ to https://xxxx.xxxxx.xxxx. Now the build are failing. The first part of the builds OK where it Prepares (see below)

The project builds and the unit tests run, then it goes into the 2nd part of the sonarqube. I’m not sure what to check next.

******************************************************************************
Starting task: Prepare the SonarQube analysis
******************************************************************************
Executing the powershell script: E:\Build\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubePreBuild.ps1
SonarQube Scanner for MSBuild 4.0
Default properties file was found at E:\Build\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from E:\Build\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
10:28:56.794  Updating build integration targets...
10:28:56.825  Fetching analysis configuration settings...
10:28:57.317  Provisioning analyzer assemblies for cs...
10:28:57.317  Installing required Roslyn analyzers...
10:28:57.489  Provisioning analyzer assemblies for vbnet...
10:28:57.489  Installing required Roslyn analyzers...
10:28:57.52  Pre-processing succeeded.
******************************************************************************
Finishing task: SonarQubeScannerMsBuildBegin

Here is where it fails.

******************************************************************************
Starting task: Complete the SonarQube analysis
******************************************************************************
Executing the powershell script: E:\Build\tasks\SonarQubeScannerMsBuildEnd\3.1.0\SonarQubePostTest.ps1
SonarQube Scanner for MSBuild 4.0
Default properties file was found at E:\Build\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from E:\Build\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Post-processing started.
10:29:15.166  Fetching code coverage report information from TFS...
10:29:15.197  Attempting to locate a test results (.trx) file...
10:29:15.197  Looking for TRX files in: E:\Build\_work\1\TestResults
10:29:15.197  Located a test results file: E:\Build\_work\1\TestResults\tfsbuild_csat_svcacc_TFS-CI-P1 2018-11-15 10_29_10.trx
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: E:\Build\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\sonar-scanner-3.0.3.778\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: E:\Build\_work\1\.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_181 Oracle Corporation (64-bit)
INFO: Windows Server 2012 R2 6.3 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\TFSBuild_CSAT_SVCACC\.sonar\cache

ERROR: SonarQube server [https://xxxxxx.xxxxxxxx.com] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.765s
INFO: Final Memory: 4M/77M
INFO: ------------------------------------------------------------------------

ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
    at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
    at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:100)
    at org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.java:76)
    at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
    at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)
    ... 8 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at sun.security.ssl.Handshaker.process_record(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectTls(RealConnection.java:267)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.establishProtocol(RealConnection.java:237)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:148)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:186)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:63)
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
    at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:96)
    ... 12 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
    ... 42 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
    at java.security.cert.CertPathBuilder.build(Unknown Source)
    ... 48 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
10:29:16.738  Creating a summary markdown file...
10:29:16.738 Post-processing failed. Exit code: 1
System.Exception: Unexpected exit code received from batch file: 1
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeBatchScriptCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
Waiting on the SonarQube server to finish processing in order to determine the quality gate status.
System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407 ---> System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at Microsoft.TeamFoundation.DistributedTask.Handlers.PowerShellHandler.Execute(ITaskContext context, CancellationToken cancellationToken, Int32 timeoutInMinutes)
at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.RunTask(ITaskContext context, TaskWrapper task, CancellationTokenSource tokenSource)
******************************************************************************
Finishing task: SonarQubeScannerMsBuildEnd
******************************************************************************
System.Exception: Task SonarQubeScannerMsBuildEnd failed. This caused the job to fail. Look at the logs for the task for more details.
at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource)
Worker Worker-5d092cfb-ffb6-4b94-b2a7-18d0affc43a4 finished running job 5d092cfb-ffb6-4b94-b2a7-18d0affc43a4
******************************************************************************
Finishing Build
******************************************************************************

(G Ann Campbell) #2

Hi,

As I understand it, the begin step essentially turns on eavesdropping on your build. It’s the end step that takes the data collected during eavesdropping and actually performs analysis. So your analysis is essentially failing at the beginning… when it tries to contact your SonarQube instance for the first time.

You’ve got a configuration somewhere (a SonarQube instance definition? Sorry, TFS analysis is not my strong suit) telling analysis where to find your SonarQube instance. You need to update it with the new URL.

 
HTH,
Ann


(Patrick Delaney) #3

The eavesdropping step is working. Yes I did update the URL. I even put a bogus URL in and then the eavesdropping failed. When I changed it to the new URL the eavesdropping worked but the analysis connection fails


(Duarte Meneses) #5

Hi Patrick,

Looks like the Java process is having problems connecting to SonarQube due to an authentication problem - it’s not trusting the server’s certificate.
So if this problem is new, probably either a new certificate was installed in the server or the Java runtime was changed and no longer trusts the server’s certificate.
You will probably need to add the certificate to the JVM’s truststore, usually in [java_home]/lib/security/cacerts.