SonarCloud Azure DevOps auto integration for pull request quality gate result

Hi, what I want achive is when a new repo created on Azure DevOps I would like the repo has all the security and branch policies automaticly, the part related to SonarCloud is “Require approval from additional services - Add status policy” setting in branch policy page.

Now to be able to add this quality gate check for PRs I need to do following manuel repetitive job sequence for every newly created repository.

When a new repo is created I have to go to SonarCloud and at project settings I need to select Azure DevOps for Pull Request settings and provide PAT for it. Which needs to be builded in the first place to be seen on SonarCloud but we want to create an empty master branch than push code to master from a feature branch with pull request and see SonarCloud analysis results on that PR.

When a new repo created I have to add some code because if I want to add status check from SonarCloud first I need to be able to build and analyze the project to see it on sonar by this way I can go to project settings and make pull request settings for project than I have to make a pull request to master branch to be able to see SonarCloud pull request option on branch policies dropdown menu at Azure DevOps - Require approval from additional services - Add status policy - Status to check.

How can I automate this process for SonarCloud part?

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Scanner command used when applicable (private details masked):
  - task: SonarCloudPrepare@1
          SonarCloud: 'MesheSonarConnection'
          organization: '(private details masked)'
          scannerMode: 'MSBuild'
          projectKey: $(Build.Repository.Name)
          projectName: $(Build.Repository.Name)
          extraProperties: |
         Build Task
         Test Task

       - task: SonarCloudAnalyze@1
         continueOnError: false

Hi @hamza_sag and welcome to the community !

Thank you for your feedback.

This kind of automation is not yet supported on SonarCloud, but that’s definitely a good idea, and we’ll keep that in mind for the future.

In the mean time, we are working on a new onboarding experience for Azure DevOps (but may not have the feature you described), it should ease the setup of new projects, stay tuned for that !