Sonarcloud Azure DevOps with code repository at github.com

I want to setup PR analysis of a .NET code base.

  • ALM used
    GitHub
  • CI system used
    Azure DevOps

However, I keep getting;

14:51:45.817 INFO: Load project branches
14:51:45.860 DEBUG: GET 200 https://sonarcloud.io/api/project_branches/list?project=***_Platform | time=43ms
14:51:45.866 INFO: Load project branches (done) | time=49ms
14:51:45.868 INFO: Check ALM binding of project '***_Platform'
14:51:45.903 DEBUG: GET 200 https://sonarcloud.io/api/alm_integration/is_project_bound?project=***_Platform | time=34ms
14:51:45.905 INFO: Detected project binding: BOUND
14:51:45.905 INFO: Check ALM binding of project '***_Platform' (done) | time=37ms
14:51:45.906 INFO: Load project pull requests
14:51:45.939 DEBUG: GET 200 https://sonarcloud.io/api/project_pull_requests/list?project=***_Platform | time=32ms
14:51:45.943 INFO: Load project pull requests (done) | time=37ms
14:51:45.947 INFO: Load branch configuration
14:51:45.948 DEBUG: Found manual configuration of branch/PR analysis. Skipping automatic configuration.
14:51:46.067 DEBUG: GET 404 https://sonarcloud.io/api/alm_integration/show_pullrequest?project=***_Platform&pullrequestKey=450 | time=114ms
14:51:46.074 INFO: ------------------------------------------------------------------------
14:51:46.074 INFO: EXECUTION FAILURE
14:51:46.074 INFO: ------------------------------------------------------------------------

I am suspecting that the findings of manual configuration is the issue. However, I have not done any to my configuration of branch/PR analysis. Do I need some other configuration for this setup? I have not been able to find any solutions yet.

Hey there.

By all means, this should work (GitHub ALM + Azure Devops CI with SonarCloud analysis).

  • How is your azure-pipelines.yml configured? Feel free to paste it here.
  • Does your project show as being bound to GitHub?

I also read that it should be. So far I haven’t had any luck with it.

azure-pipeline.yml (snippet):

...
- task: SonarCloudPrepare@1
            displayName: 'Prepare analysis configuration'
            inputs:
              SonarCloud: 'SonarCloud'
              organization: '******'
              scannerMode: 'MSBuild'
              projectKey: '*******'
              projectName: '******'
              extraProperties: |
                sonar.verbose=true

          - task: DotNetCoreCLI@2
            displayName: Dotnet build
            inputs:
              command: build
              projects: '******.sln'
              arguments: '--no-restore --configuration Release /p:Version=$(semVersion)'

          - task: DotNetCoreCLI@2
            displayName: Dotnet test
            inputs:
              command: test
              arguments: '--no-build --configuration Release --collect:"XPlat Code Coverage"'

          - task: SonarCloudAnalyze@1
            displayName: 'Run SonarCloud analysis'

          - task: SonarCloudPublish@1
            displayName: 'Publish results on build summary'
...

No, it is bound to Azure DevOps. I still haven’t completed the first analysis which I guess will make main branch, pull requests and branches buttons enabled and not greyed out.

And that would be the issue – SonarCloud is looking for the pull request on Azure DevOps, not on GitHub.

How is your repository bound to Azure DevOps if the source code is on GitHub? Presumably, the repository doesn’t exist on Azure DevOps (which you selected when you created a project).