Version: Sonar Cloud
Code Repository: Azure Repos Git
Integration: Azure DevOps Services
Languages of the repository: Python and C#/Dotnet
ScannerMode: CLI for Python and MSBuild for C#/Dotnet
Issue Description:
A dataproduct contains code snippet for Web API developed on C# and Azure databrick notebook using python. We have multiple dataproducts similar to it which mainly uses python and C# stored in single monorepository.
We are having Python and C#/dotnet projects in Azure Git repository. We have imported the code as monorepo (single) private project in sonarcloud and enabled monorepo support in the project settings as well. We have to do sonarcloud analysis for both python and dotnet/C# languages in single Azure DevOps pipeline. After executing the pipeline python code analysis results has been overwritten by the dotnet/C# code analysis results (First code analysis result(Python) has been overriden by the second code analysis task (C#))
Based on the documentation we must create sonarcloud project for each language(Python and dotnet/C#) which is monotonous to maintain.
Please let us know the reason for it and provide the best solution for this issue.
Steps to reproduce:
Add two build tasks for Python and C# code analysis in single yaml pipeline
jobs:
- job: "BuildForPython"
steps:
- task: SonarCloudPrepare@1
displayName: Prepare Analysis on SonarCloud for Python
inputs:
SonarCloud: '$(sonarCloudServiceConnection)'
organization: '$(sonarCloudOrganisation)'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: '$(sonarCloudProjectKey)'
cliProjectName: '$(sonarCloudProjectName)'
cliSources: 'samplepythonproject'
- task: SonarCloudAnalyze@1
displayName: Run Code Analysis
- task: SonarCloudPublish@1
displayName: Publish Python Code Analysis Results
inputs:
pollingTimeoutSec: '300'
- job: "BuildForCSharp"
steps:
- task: SonarCloudPrepare@1
displayName: Prepare Analysis on SonarCloud for .NET
inputs:
SonarCloud: $(sonarCloudServiceConnection)
organization: $(sonarCloudOrganisation)
projectKey: $(sonarCloudProjectKey)
projectName: $(sonarCloudProjectName)
scannerMode: 'MSBuild'
extraProperties: >
sonar.source= 'sampledotnetproject'
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.csproj'
displayName: 'Restore Nuget Packages'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--no-restore'
displayName: 'Build projects'
- task: SonarCloudAnalyze@1
displayName: Run Code Analysis
- task: SonarCloudPublish@1
displayName: Publish C# Code Analysis Results
inputs:
pollingTimeoutSec: '300'