SCM provider autodetection failed for Azure Devops pipeline

In the hope that the forum may be useful to some - the issue here was that the analysis was being performed at the wrong level when source code was checked out into the Azure DevOps pipeline.

The issue was seen in the pull-request where the path prefix was wrong (not sure why as it was working previously):

By setting sonar.projectBaseDir on the SonarCloudPrepare task to the Azure DevOps pipeline variable Build.SourcesDirectory the warning in the analysis run went away and the problem of incorrect issues being reported went too (I believe that is due to the SCM identification now working correctly).

- task: SonarCloudPrepare@1
    displayName: 'Analysis: Prepare SonarCloud Analysis'
    inputs:
      sonarCloud: ${{parameters.sonarCloud.cloud}}
      organization: ${{parameters.sonarCloud.organization}}
      projectKey: ${{parameters.sonarCloud.projectKey}}
      projectName: ${{parameters.sonarCloud.projectName}}
      extraProperties: |
        ${{parameters.sonarCloud.extraProperties}}
        **sonar.projectBaseDir=$(Build.SourcesDirectory)**
1 Like