sonar-scanner-msbuild icon indicating copy to clipboard operation
sonar-scanner-msbuild copied to clipboard

Symlinks cause sonar analysis to fail when using Concourse with Windows worker

Open jstaley opened this issue 6 years ago • 9 comments

Description

Running Sonar scanner via Concourse fails with path issues

Repro steps

Create pipeline using Concourse. Run the analysis on Windows with Concourse. Scanner fails to find files due to symlink issue. Concourse symlinks the source repository to containers/live. This causes the analysis to fail with referenced file erros

  1. Step A

  2. Step B

If possible then please create a git repository with a repro sample or attach a zip to the issue.

Expected behavior

The analysis path to the file is the same as the sonar output

Actual behavior

File paths do not match.

INFO: Importing results from 6 proto files in 'D:\concourse\containers\containers\00002657kgj\tmp\build\b27bb238\source-git.sonarqube\out\0\output-cs' WARNING: WARN: File 'D:\concourse\containers\volumes\live\4c6444de-0791-481f-7dd8-f70df6d9e920\volume\src\netcore2_api_template\Controllers\ValuesController.cs' referenced by the protobuf 'MetricsInfo' does not exist in the analysis context WARNING: WARN: File 'D:\concourse\containers\volumes\live\4c6444de-0791-481f-7dd8-f70df6d9e920\volume\src\netcore2_api_template\Program.cs' referenced by the protobuf 'MetricsInfo' does not exist in the analysis context WARNING: WARN: File 'D:\concourse\containers\volumes\live\4c6444de-0791-481f-7dd8-f70df6d9e920\volume\src\netcore2_api_template\Providers\CustomValueProvider.cs' referenced by the protobuf 'MetricsInfo' does not exist in the analysis context WARNING: WARN: File 'D:\concourse\containers\volumes\live\4c6444de-0791-481f-7dd8-f70df6d9e920\volume\src\netcore2_api_template\Startup.cs' referenced by the protobuf 'MetricsInfo' does not exist in the analysis context

Known workarounds

None

Related information

SonarScanner for MSBuild 4.3.1 Using the .NET Core version of the Scanner for MSBuild Default properties file was found at C:\Users\concourse.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\SonarQube.Analysis.xml Loading analysis properties from C:\Users\concourse.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\SonarQube.Analysis.xml Post-processing started. SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m Calling the SonarQube Scanner... INFO: Scanner configuration file: C:\Users\concourse.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\sonar-scanner-3.2.0.1227\bin..\conf\sonar-scanner.properties INFO: Project root configuration file: D:\concourse\containers\containers\00002657kgj\tmp\build\b27bb238\source-git.sonarqube\out\sonar-project.properties INFO: SonarQube Scanner 3.2.0.1227 INFO: Java 1.8.0_151 Oracle Corporation (64-bit) INFO: Windows Server 2012 R2 6.3 amd64 INFO: SONAR_SCANNER_OPTS=-Xmx1024m INFO: User cache: C:\Users\concourse.sonar\cache INFO: SonarQube server 7.0.0

jstaley avatar Jun 19 '18 02:06 jstaley

This seems to be a general problem with SonarScanner for MSBuild 4.3.1. I am running this via TeamCity on an agent that has the work directory set to a relative path of the agent installation. Agent is installed on a symlink to another drive (eg. c:\buildagent is a symlink to e:\apps\buildagent).

When it runs with this setup, the builds and testing are done on the symlink drive but the end results are written to the actual drive, which results in all of the protobuf files not being read by the scanner.

I 'fixed' this by changing the work directory on the agent to be the absolute path to the actual location instead of using the symlink. Ideally the scanner should be able to handle symlinks properly.

victrola0000 avatar Aug 22 '18 08:08 victrola0000

Same issue. Guys any updates?

jakubprusak avatar Oct 12 '18 11:10 jakubprusak

Hi @jakubprusak, Sorry we haven't been able to work on this topic yet. We will keep you in touch with updates.

Evangelink avatar Oct 12 '18 11:10 Evangelink

Hi @jstaley, @victrola0000 and @jakubprusak,

Has one of you been able to test newer versions of the scanner for msbuild? If so are you still experiencing the issue?

Evangelink avatar Nov 27 '18 17:11 Evangelink

@Evangelink The last time I checked it was still happening.
Using sonarscanner msbuild 4.4.2.1543

victrola0000 avatar Nov 28 '18 11:11 victrola0000

Hi @victrola0000,

Thanks! We will have a look this week.

Evangelink avatar Nov 28 '18 17:11 Evangelink

I'm getting similar warnings with the Azure DevOps integration with SonarCloud. Is there a workaround?

MisinformedDNA avatar Dec 20 '18 06:12 MisinformedDNA

Potentially related community issue: https://community.sonarsource.com/t/scanner-for-msbuild-via-jenkins-not-analyzing-cs-files/21872/3

duncanp-sonar avatar Mar 25 '20 10:03 duncanp-sonar

cc @tom-howlett-sonarsource for consideration as I've removed Support milestone.