Monorepo projects

Use these instructions to set up your build pipeline in Azure DevOps when analyzing monorepo projects in SonarQube Cloud.

You can add the SonarQube Cloud analysis to your Azure build pipeline for a monorepo.

Proceed as follows:

  1. If not already done, import your monorepo to create the corresponding projects in SonarQube Cloud: see the Monorepo support page.

  2. For each project, configure yourAnalysis parameters.

  3. For each project, set up the integration features. See the Azure DevOps page for more details.

  4. Add the SonarQube Cloud analysis to your YAML pipeline. To do so, see the section corresponding to your project type and use the YAML file example below add analysis to a:

Typical YAML file example for a monorepo analysis

# Template pipeline that build 2 distinct .NET projects, living in 2 separate folders in the repo. We are analyzing them on SonarQube Cloud, each targets a specific SonarQube Cloud project.
 
 
trigger:
- master
 
pool:
 vmImage: windows-latest
 
steps:
- task: VisualStudioTestPlatformInstaller@1
 inputs:
   packageFeedSelector: 'nugetOrg'
   versionSelector: 'latestPreRelease'
 
- task: UseDotNet@2
 inputs:
   packageType: 'sdk'
   version: '6.x'
   includePreviewVersions: true
 
- task: NuGetToolInstaller@1
 inputs:
   versionSpec: '5.9.0'
   checkLatest: true
 
- task: DotNetCoreCLI@2
 inputs:
   command: 'restore'
   projects: '**/*.sln'
   feedsToUse: 'select'
 
- task: SonarCloudPrepare@3
 inputs:
   SonarCloud: '<YourSonarqubeServiceEndpoint>'
   scannerMode: 'dotnet'
   projectKey: 'myRepo_myProject1'
 
- task: DotNetCoreCLI@2
 inputs:
   command: 'build'
   projects: 'myproject1/solution.sln'
   arguments: '/nr:false' // this flag is important to avoid DLL lock for the 2nd build/analysis
 
- task: SonarCloudAnalyze@3
 
- task: SonarCloudPrepare@3
 inputs:
   SonarCloud: '<YourSonarqubeServiceEndpoint>'
   scannerMode: 'dotnet'
   projectKey: 'myRepo_myProject2'
 
- task: DotNetCoreCLI@2
 inputs:
   command: 'build'
   projects: 'myProject2/solution.sln'
   arguments: '/nr:false'
 
- task: SonarCloudAnalyze@3

Last updated

Was this helpful?