Pull Request Analysis for .NET code

Running Latest LTE of SonarQube Developer
Deployed via zip on a windows machine

Hello All,

I am trying to incorperate Pull Request Analysis (In Azure DevOps) so that before a merge happens, it must pass the quality gate conditions. Im a bit confused for how this works with .NET code since the Sonar Analysis happens during the BUILD process in the pipeline.

What ive done so far:

  • Created the DevOps Platform Integrations. (Used a PAT with read and write permissions)

  • Created the Build Validation for the specific pipeline i want

  • Created the Status Check and used “SonarQube/quality gate” as the “Status to Check”

  • We are using the final yaml code for the sonarqube prep, analysis and publish:

    • task: SonarQubePrepare@7
      inputs:
      SonarQube: ‘HT-MARGA-SONARQUBE-SCN’
      scannerMode: ‘dotnet’
      projectKey: ‘APIv6-SupplyProductSearch’
      projectName: ‘APIv6-SupplyProductSearch’
      projectVersion: ‘2.0’

    • task: SonarQubeAnalyze@7
      condition: eq(variables[‘Build.SourceBranch’], ‘refs/heads/main’)

    • task: SonarQubePublish@7
      condition: eq(variables[‘Build.SourceBranch’], ‘refs/heads/main’)
      inputs:
      pollingTimeoutSec: ‘300’

When i try and pull request to test this…it gets stuck on the Status Check (Waiting…)

Am i missing anything? Maybe some configs on the quality gate in SQ server?

Also…im a bit confused with how the PR analysis works with .NET code since the SQ analysis takes place during the build process…So how does SQ analyze the new code that is wanting to be merged into the target branch?

Any help is appreciated.

Thanks!

Hi,

I’m not seeing a ‘build’ task in there. Am I misunderstanding something? You need to begin, then build, then end, and then publish.

PR analysis is performed against the feature branch before merge. And yes, you’ll have to run a full build on it first.

Does that help?

 
Ann

got it figured it out! thank you!

1 Like