SonarCloud, Azure Devops, Local Agent and Firewalls

  • ALM used (Azure DevOps)
  • CI system used ( Azure DevOps, Local Build Agent)
  • Languages of the repository: C#
    Currently having an issue when trying to setup SonarCloudPrepare on a local agent behind a firewall to Azure Devops

At first got the following error

Starting: SonarCloudPrepare
==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarCloud analysis configuration
Version      : 1.39.0
Author       : sonarsource
Help         : Version: 1.39.0. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
==============================================================================
##[error][SQ] API GET '/api/server/version' failed, error is connect ECONNREFUSED 18.155.229.118:443
Finishing: SonarCloudPrepare

After reading a few random articles here and there, attempted to set windows proxy (didnt work)
Added a proxy env var HTTP_PROXY and HTTPS_PROXY
Then new error appeared

Starting: SonarCloudPrepare
==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarCloud analysis configuration
Version      : 1.39.0
Author       : sonarsource
Help         : Version: 1.39.0. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
==============================================================================
##[error][SQ] API GET '/api/server/version' failed, error is write EPROTO 6080:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:

Finishing: SonarCloudPrepare

Yaml im using is as follows

 - task: SonarCloudPrepare@1
        displayName: Prepare Code Analysis
        inputs:
          SonarCloud: '#REDACTED#'
          organization: '#REDACTED#'
          scannerMode: 'MSBuild'
          projectKey: '#REDACTED#'
          projectName: '#REDACTED#'          
          extraProperties: |
            # Additional properties that will be passed to the scanner, 
            # Put one key=value per line, example:            
            sonar.verbose=true
            sonar.exclusions=#REDACTED#
            sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/coverage.opencover.xml    

I dont see any issues with the config and if we use a Azure Hosted Agent we do connect successfully
Im guessing it is having an issue with the proxy etc and the firewall or something is blocking access.
Just wondering if anyone else has had these errors (specifically the second one) and any resolutions to it?

Hi, we are having the same issue. The plugin on Azure DevOps seems to have been updated recently.
We changed the “Sonarcloud prepare” task to reference the 1.38.0 version of the plugin and that seems to work, but all the versions after that seems to be broken. It also looks like the “Publish results” task needs to be pinned to 1.13.0 as that is also broken in the same way.

We are getting the issue for all sonarcloud scans. .net, java, js etc.

These work
task: SonarCloudPrepare@1.38.0
task: SonarCloudPublish@1.13.0

Hey @sbutler

To confirm, did you have a working configuration until yesterday/today identical to the one that isn’t working now?

Hey @sbutler and @adam.aucamp

Quick update. A v1.44.1 of the SonarCloud extension is coming with the same fix as v5.17.1 of the SonarQube extension. Give us ~1 hour. :smiley:

1 Like

Hi, yes that is correct. we did not change anything, it just stopped working yesterday. We checked the Azure DevOps extensions and saw that the plugin was updated just before the issue started.

This didn’t fix the problem for us. We are running the tasks (Prepare analysis 1.40.1) behind a proxy and the message still is ERR_SECURE_CONNECT_FAIL combined with ERR_BAD_RESPONSE.

The last working Prepare task was 1.38.0.

Same here. We are running the tasks (Prepare analysis 1.40.1) from a self-hosted Azure DevOps agent behind a proxy.

The last working Prepare analysis version was 1.38.0 which was pushed on August 9.

Hi all,

The fix was released about an hour ago. Can you confirm that you’re still having problems in runs since then?

 
Thx,
Ann

Yes, we are using the latest (1.40.1) prepare task, from the SonarCloud 1.44.1 extension and the problem remains.

1 Like

Hi, the problem still persists with version 1.44.1

1 Like

Same here, version 1.44.1 of the extension carrying the latest version of the Prepare Analysis task (1.40.1) did not fix this issue.

1 Like

Hi,

Thanks all! We’re back at the drawing board.

 
Ann

2 Likes

We got the same problem,

[SQ] API GET ‘/api/server/version’ failed, error is Request failed with status code 400
SonarCloud Prepare

1 Like

We also seem to be impacted by this.

##[error][SQ] API GET ‘/api/server/version’ failed, error is Request failed with status code 500

1 Like

Hi Colin,
We have just started implementing SonarCloud. so never have had it working with our local build agent.

I notice you have reverted the use of axios and pushed a new version. I can confirm that extension version 1.44.2 with Prepare Analysis task version 1.40.2 has fixed the issue.

1 Like

Our issue fixed with the reverted version,
On the pipeline below task versions were used.
Downloading task: SonarCloudPrepare (1.40.2)
Downloading task: SonarCloudAnalyze (1.43.2)
Downloading task: SonarCloudPublish (1.15.2)

1 Like

Using Extension 1.44.2
and version 1.40.2 for task SonarCloudPrepare
Still having issues, (even though now gets further)
I can see agent is running behind proxy in the Init Job Section.
once it tries to run Prepare step it fails but further along

Compared to previous flags only change was setting the version number

- task: SonarCloudPrepare@1.40.2
Starting: SonarCloudPrepare
==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarCloud analysis configuration
Version      : 1.40.2
Author       : sonarsource
Help         : Version: 1.40.2. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
==============================================================================
C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:Bell-Financial_Onboarding.Service /o:bell-financial-group
SonarScanner for MSBuild 5.14
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
09:17:23.392  09:17:23.376  Loading analysis properties from C:\agent\_work\_tasks\SonarCloudPrepare_#redacted#\1.40.2\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
09:17:23.392  09:17:23.392  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
09:17:23.408  Updating build integration targets...
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
09:17:23.408  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
09:17:23.408  Installed SonarQube.Integration.targets to C:\agent\_work\15\.sonarqube\bin\targets
09:17:23.408  Creating config and output folders...
09:17:23.408  Creating directory: C:\agent\_work\15\.sonarqube\conf
09:17:23.408  Creating directory: C:\agent\_work\15\.sonarqube\out
09:17:23.439  Fetching server version...
09:17:23.439  Downloading from https://sonarcloud.io/api/server/version...
##[error]09:17:31.691  Unable to connect to server. Please check if the server is running and if the address is correct. Url: 'https://sonarcloud.io/api/server/version'.
09:17:31.691  Unable to connect to server. Please check if the server is running and if the address is correct. Url: 'https://sonarcloud.io/api/server/version'.
09:17:31.691  System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 18.155.229.118:443
   at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
##[error]09:17:31.691  An error occured while querying the server version! Please check if the server is running and if the address is correct.
09:17:31.691  An error occured while querying the server version! Please check if the server is running and if the address is correct.
##[error]09:17:31.691  Pre-processing failed. Exit code: 1
09:17:31.691  Pre-processing failed. Exit code: 1
##[error]The process 'C:\agent\_work\_tasks\SonarCloudPrepare_#redacted#\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: SonarCloudPrepare

Hi @sbutler,

You’re failing with the latest version on the first call to SonarCloud. Can you verify that there’s nothing “helpful” on the network that may be interfering?

Also, Colin asked this earlier and I’m not sure you responded:

 
Thx,
Ann