# SonarQube analysis task failing when checking out multiple repositories in single Azure DevOps YAML

**URL:** <https://community.sonarsource.com/t/sonarqube-analysis-task-failing-when-checking-out-multiple-repositories-in-single-azure-devops-yaml/114803>\
**Category:** SonarQube Server / Community Build\
**Tags:** dotnet\
**Created:** [May 6, 2024, 3:59pm UTC](https://community.sonarsource.com/t/sonarqube-analysis-task-failing-when-checking-out-multiple-repositories-in-single-azure-devops-yaml/114803 "2024-05-06T15:59:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g3orge](https://avatars.discourse-cdn.com/v4/letter/g/90ced4/32.png) [@g3orge](https://community.sonarsource.com/u/g3orge)\
**Post date:** [May 6, 2024, 3:59pm UTC](https://community.sonarsource.com/t/sonarqube-analysis-task-failing-when-checking-out-multiple-repositories-in-single-azure-devops-yaml/114803/1 "2024-05-06T15:59:11Z")

</div>

The SonarQube analysis task failing when checking out multiple repositories in single Azure DevOps YAML pipeline.  
The pipeline runs on a windows VM hosted build agent.  
There is a single project setup in a SonarQube Community instance running on a separate VM.  
We only require analysis on the second repository’s code.  
The first repository source is used to run pwsh scripts in the same YAML pipeline.

The base directory path seems to get overwritten from “C:\azp\agent\_work\14\My-Api-Proj\Source\Services” to “C:\azp\agent\_work\14\s” as soon as I try to checkout the second directory.

We have tried specifying the sonar.sources and projectBaseDir without any success but, as soon as we disable the checkout of the first repository the analysis task works perfectly.

Why can’t I checkout multiple repositories in one YAML pipeline when only running analysis on a one of them?

Pipeline and logs as follows:

**template.yaml:**

```yml
parameters:
  - name: jobName
    type: string
  - name: repositoryName
    type: string
  - name: repositoryResourceName
    type: string
  - name: slnBuildPath
    type: string
  - name: testProjRootPath
    type: string
  - name: agentPool
    type: string
  - name: projectKey
    type: string  

jobs:
  - job: ${{ parameters.jobName }}
    pool: ${{ parameters.agentPool }}
    continueOnError: false
    workspace:
      clean: outputs
    steps:
      - checkout: repoMigrations
        displayName: Checkout Migrations Repo
        path: Migrations
        
      - task: PowerShell@2
        displayName: Run script DbMigrations/DBDeployment.ps1
        inputs:
          filePath: $(Agent.BuildDirectory)/Migrations/DbMigrations/DBDeployment.ps1
          workingDirectory: $(Agent.BuildDirectory)/Migrations/DbMigrations
          arguments: '-connection_string "$(az-psql-we-migrations-connection-string)"'
        continueOnError: false  

      - checkout: ${{parameters.repositoryResourceName}}
        clean: true
        submodules: recursive
        persistCredentials: true
        path: ${{ parameters.repositoryName }}  

      # Sonar prepare
      - task: SonarQubePrepare@5
        inputs:
          SonarQube: 'SonarQubeConn'
          scannerMode: 'MSBuild'
          projectKey: ${{ parameters.projectKey }}
          extraProperties: |
            sonar.sources=$(Agent.BuildDirectory)\${{ parameters.repositoryName }}\${{ parameters.testProjRootPath }}
            sonar.projectBaseDir=$(Agent.BuildDirectory)\${{ parameters.repositoryName }}\${{ parameters.testProjRootPath }}
            sonar.verbose=true  

      # Build .sln
      - task: DotNetCoreCLI@2
        displayName: Build ${{ parameters.slnBuildPath }}
        inputs:
          command: build
          projects: $(Agent.BuildDirectory)\${{ parameters.repositoryName }}\${{ parameters.slnBuildPath }}
          arguments: '--configuration ${{ parameters.buildConfiguration }}'
        continueOnError: false  

      # Run unit tests
      - task: DotNetCoreCLI@2
        displayName: Run Unit Tests
        inputs:
          command: test
          projects: |
            $(Agent.BuildDirectory)\${{ parameters.repositoryName }}\${{parameters.testProjRootPath}}\**\*Tests.csproj  

      # Sonar analyse - Fails when checking out multiple repos
      - task: SonarQubeAnalyze@5
        displayName: Run Code Analysis  

      - task: SonarQubePublish@5
        displayName: Publish Quality Gate Result

```

```log
Starting: SonarQubePrepare
==============================================================================
Task : Prepare Analysis Configuration
Description : Prepare SonarQube analysis configuration
Version : 5.19.1
Author : sonarsource
Help : Version: 5.19.1. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
C:\azp\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:RIB-BIM_6D_BIM6D-Api_AY51MPl40d9uQHUzMowH
SonarScanner for MSBuild 5.15
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
12:24:41.14 Updating build integration targets...
12:24:41.347 Fetching analysis configuration settings...
12:24:41.739 Provisioning analyzer assemblies for cs...
12:24:41.739 Installing required Roslyn analyzers...
12:24:41.739 Processing plugin: csharp version 9.13.0.79967
12:24:41.865 Processing plugin: vbnet version 9.13.0.79967
12:24:42.038 Provisioning analyzer assemblies for vbnet...
12:24:42.038 Installing required Roslyn analyzers...
12:24:42.038 Processing plugin: csharp version 9.13.0.79967
12:24:42.038 Processing plugin: vbnet version 9.13.0.79967
12:24:42.054 Incremental PR analysis: Base branch parameter was not provided.
12:24:42.054 Cache data is empty. A full analysis will be performed.
12:24:42.101 Pre-processing succeeded.
Finishing: SonarQubePrepare
...
Starting: Run Code Analysis
==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarQube server.
Version : 5.20.0
Author : sonarsource
Help : Version: 5.20.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
C:\azp\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 5.15
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
12:27:17.853 12:27:17.853 WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed. Project file: "c:\users\containeradministrator\appdata\local\temp\kw2tvvaq.h3w\workerextensions.csproj"
12:27:17.853 12:27:17.853 WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed. Project file: "c:\users\containeradministrator\appdata\local\temp\4eyipxnt.3rq\workerextensions.csproj"
12:27:17.853 12:27:17.853 WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed. Project file: "c:\users\containeradministrator\appdata\local\temp\s4fuq12b.k2i\workerextensions.csproj"
12:27:17.853 12:27:17.853 WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed. Project file: "c:\users\containeradministrator\appdata\local\temp\cz3pr5de.5xy\workerextensions.csproj"
12:27:17.885 12:27:17.885 WARNING: File 'C:\azp\agent\_work\14\BIM6D-Api\Candy\Source\CCS.Shared.Services\CCS.Infrastructure\CCS.Core.NetCore\Infrastructure\IOperatingSystemHelper.cs' is not located under the base directory 'C:\azp\agent\_work\14\s' and will not be analyzed.
12:27:17.885 12:27:17.885 WARNING: File 'C:\azp\agent\_work\14\BIM6D-Api\Candy\Source\CCS.Shared.Services\CCS.Infrastructure\CCS.Core.NetCore\Infrastructure\OperatingSystemHelper.cs' is not located under the base directory 'C:\azp\agent\_work\14\s' and will not be analyzed.
12:27:17.885 12:27:17.885 WARNING: File 'C:\azp\agent\_work\14\BIM6D-Api\Candy\Source\CCS.Shared.Services\CCS.Infrastructure\CCS.Infrastructure.Common\Clone\IClonable.cs' is not located under the base directory 'C:\azp\agent\_work\14\s' and will not be analyzed.
...
##[error]12:27:18.057 No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
12:27:18.057 No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
12:27:18.057 Generation of the sonar-properties file failed. Unable to complete the analysis.
##[error]12:27:18.073 Post-processing failed. Exit code: 1
12:27:18.073 Post-processing failed. Exit code: 1
##[error]The process 'C:\azp\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: Run Code Analysis

```

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [May 7, 2024, 12:37pm UTC](https://community.sonarsource.com/t/sonarqube-analysis-task-failing-when-checking-out-multiple-repositories-in-single-azure-devops-yaml/114803/2 "2024-05-07T12:37:51Z")

</div>

Hi,

Welcome to the community!

> [@g3orge](#):
>
> The base directory path seems to get overwritten from “C:\azp\agent\_work\14\My-Api-Proj\Source\Services” to “C:\azp\agent\_work\14\s” as soon as I try to checkout the second directory.

Is this an environment variable you’re talking about? Because analysis works on the directory it’s invoked from.

Since we’re talking about .NET analysis here, the bulk of analysis happens during the build, which you seem to have redacted from the log you posted. Could you post the whole thing, start to finish?

Also, since you have doubts about what values analysis is running with I think it’s worth a run with `sonar.scanner.dumpToFile=[path to file]` so you / we can see exactly what those values are. (Hopefully you have access to the work directory post-run to retrieve the file.)

&nbsp;  
Ann
