Hi, we seem to have observed a regression with the release of SonarCloud Azure DevOps extension v3.0.3
.
We configure SonarCloud to work in mono-repository setup, analyzing one C# project at a time.
The typical SonarCloudPrepare@2
(prior to migration to @3
) looked like this:
- task: SonarCloudPrepare@2
inputs:
SonarCloud: "SonarCloud"
organization: "<ORGANIZATION>"
scannerMode: "dotnet"
projectKey: "${{ parameters.sonarProjectKey }}"
projectVersion: "$(Build.BuildNumber)"
extraProperties: |
sonar.cs.opencover.reportsPaths=${{ parameters.workingDirectory }}/test_output/Coverage/*/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
sonar.projectBaseDir=${{ parameters.workingDirectory }}
We recently updated all tasks to @3
version, which worked for some time. However, on 30.10.2024 our builds started to fail because task SonarCloudAnalyze@3
was no longer able to find sources to analyze. After examining the logs, we discovered that SonarCloud no longer respects sonar.projectBaseDir
. While I cannot share logs directly, every single file that should be anayzed produced the following warning:
12:39:24.422 WARNING: File '/home/vsts/work/1/project/<projet-name-in-monorepo>/tests/SomeCode.cs' is not located under the base directory '/home/vsts/work/1/s' and will not be analyzed.
Notice that /home/vsts/work/1/s
is a wrong base directory. The value of ${{parameters.workingDirectory}}
is /home/vsts/work/1/project/<projet-name-in-monorepo>
, and all sources are found in its subfolders.
We wasted half a day debugging CI until I pinned the version of all three SonarCloud tasks (SonarCloudPrepare
, SonarCloudAnalyze
, and SonarCloudPublish
) to @3.0.2
, which immediately resolved all the issues for us across the board.
Now I believe that we might have a suboptimal configuration, yet it worked perfectly fine until a minor (!) release by Sonar, which destroyed half of our deployment processes. I failed to find any other similar issue reported, so perhaps it is a unique situation, and at this points I have no resources to debug it further, so I’d welcome any insights in the issue.
(I did not debug which combination of @3.0.3
and @3.0.2
produces the issue, I can only confirm that if all tasks are @3
resolving to @3.0.3
, it does not work, but if all tasks are @3.0.2
, it works)
- ALM used:
Azure DevOps
- CI system used:
Azure DevOps
- Scanner command used when applicable:
- task: SonarCloudPrepare@3
inputs:
SonarCloud: "SonarCloud"
organization: "<ORGANIZATION>"
scannerMode: "dotnet"
projectKey: "${{ parameters.sonarProjectKey }}"
projectVersion: "$(Build.BuildNumber)"
extraProperties: |
sonar.cs.opencover.reportsPaths=${{ parameters.workingDirectory }}/test_output/Coverage/*/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
sonar.projectBaseDir=${{ parameters.workingDirectory }}
# Build and test dotnet app
- task: SonarCloudAnalyze@3 # Here it breaks
- task: SonarCloudPublish@3
inputs:
pollingTimeoutSec: "300"
- Languages of the repository: At least
C#
- Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
12:39:24.422 WARNING: File '/home/vsts/work/1/project/<projet-name-in-monorepo>/tests/SomeCode.cs' is not located under the base directory '/home/vsts/work/1/s' and will not be analyzed.
- Steps to reproduce: Nothing, as soon as
@3
started to resolve to@3.0.3
- Potential workaround: Pinning version to
@3.0.2
, but unless it is resolved in future releases, we are stuck