Hi @ganncamp
I Did reply to Colin in regards to his reply and stated that we are just now introducing SonarCloud and is our first setup of it so never had a ‘working’ config for it using a local build agent.
We have tested with a Azure Hosted Build Agent and it seems to connect fine but requirements to use our local agents to run it when we have a full setup going.
We do have a firewall that may be blocking it, but also a proxy setup to allow the traffic through.
I can see that we have set the HTTP_PROXY and HTTPS_PROXY env vars on the agent
And in agent Job Init i can see it notes it is running behind a proxy server
Agent is running behind proxy server: #REDACTED#
have added the following PowerShell script to verify can access sonarcloud via the proxy.
Starting: PowerShell
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Linux, macOS, or Windows
Version : 2.229.4
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent\_work\_temp\7b2c3f65-7007-4bd3-aeb4-7e77c4438681.ps1'"
8.0.0.47838
Finishing: PowerShell
While immediatly afterwards failing on the sonarcloud prepare step
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:#REDACTED# /o:#REDACTED#
SonarScanner for MSBuild 5.14
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
11:25:12.436 11:25:12.264 Loading analysis properties from C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
11:25:12.436 11:25:12.436 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
11:25:12.436 Updating build integration targets...
11:25:12.451 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
11:25:12.451 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
11:25:12.467 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
11:25:12.467 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
11:25:12.482 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
11:25:12.482 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
11:25:12.482 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
11:25:12.498 Installed SonarQube.Integration.targets to C:\agent\_work\15\.sonarqube\bin\targets
11:25:12.498 Creating config and output folders...
11:25:12.498 Creating directory: C:\agent\_work\15\.sonarqube\conf
11:25:12.498 Creating directory: C:\agent\_work\15\.sonarqube\out
11:25:12.576 Fetching server version...
11:25:12.592 Downloading from https://sonarcloud.io/api/server/version...
##[error]11:25:20.79 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'.
11:25:20.79 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'.
11:25:20.837 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.67.93.35: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]11:25:20.837 An error occured while querying the server version! Please check if the server is running and if the address is correct.
11:25:20.837 An error occured while querying the server version! Please check if the server is running and if the address is correct.
##[error]11:25:20.837 Pre-processing failed. Exit code: 1
11:25:20.837 Pre-processing failed. Exit code: 1
##[error]The process 'C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: SonarCloudPrepare
Nope.
That IP address apparently is an AWS Cloudfront IP Address according to lookup tools.
Other runs have had other AWS IP’s
18.67.93.82
18.67.93.4
18.155.216.110
18.155.216.18
65.8.134.115
etc etc
all of our internal/external IP addresses are in the
192.168.x
10.17.x
103.x.x.x
ranges
It might be our proxy just blocking the connection which i would find odd as using the proxy with the command
In Particular I think it may be an issue with SonarScanner.MSBuild.exe might not be using the system proxy even though HTTP_PROXY is set
##[debug]system.debug=True
##[debug]exec tool: C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
##[debug]arguments:
##[debug] begin
##[debug] /k:#REDACTED#
##[debug] /o:#REDACTED#
C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:#REDACTED# /o:#REDACTED#
SonarScanner for MSBuild 5.14
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
10:50:29.379 10:50:29.363 Loading analysis properties from C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
10:50:29.379 10:50:29.379 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
10:50:29.379 Updating build integration targets...
10:50:29.394 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
10:50:29.394 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
10:50:29.394 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
10:50:29.394 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
10:50:29.394 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
10:50:29.394 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
10:50:29.394 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
10:50:29.394 Installed SonarQube.Integration.targets to C:\agent\_work\15\.sonarqube\bin\targets
10:50:29.394 Creating config and output folders...
10:50:29.394 Creating directory: C:\agent\_work\15\.sonarqube\conf
10:50:29.394 Creating directory: C:\agent\_work\15\.sonarqube\out
10:50:29.426 Fetching server version...
10:50:29.426 Downloading from https://sonarcloud.io/api/server/version...
##[error]10:50:37.581 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'.
##[debug]Processed: ##vso[task.logissue type=error;]10:50:37.581 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'.
10:50:37.581 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'.
10:50:37.581 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.67.93.82: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 ---
I can confirm that SonarScanner.MSBuild.exe is using the environment variable HTTP_PROXY as well as HTTPS_PROXY , ALL_PROXY , and NO_PROXY as stated in the documentation:
You also need to set the appropriate proxy environment variables used by .NET. HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and NO_PROXY are all supported. You can find more details here.
You said you set the HTTP_PROXY variable, did you also set the HTTPS_PROXY variable?
If this is not the case, SonarScanner.MSBuild.exe will not use the proxy for https connection, which is required for SonarCloud.
If this is not the issue, may I suggest, if you can, to check the log of your proxy server to see what happens when you are trying to reach SonarCloud?
That way we could be sure if SonarScanner.MSBuild.exe is using or not your proxy.
So this will probably be my last post.
According to the network team it looks like it wasn’t going out via the proxy and just hitting the firewall and getting stopped.
Have had them add the domains listed here Managing your Organization | SonarCloud Docs
and adding scanner.sonarcloud.io to the list as their firewall doesnt apparently allow wildcard domain whitelists.
After the firewall rules added the agent is able to go through all its steps as required and completes.
So a combination of adding the proxy variables and the firewall rules overall got everything working