Assigning SonarCloud Quality Gate Dynamically to scan within Azure DevOps Yaml

  • ALM Used - Azure DevOps
  • CI system used - Azure DevOps
  • Scanner Command - Integrate with MSBuild
  • SonarCloud instance is private

At my company, we are attempting to assign a specific Quality Gate at the time of a SonarCloud scan within Azure DevOps via yaml. I am not able to find anything regarding how to do this, whether it be additional commands, api calls, etc.

Is there a way to do this dynamically with SonarCloud?

Hi,

There is not. This can only be managed via the UI (or Web APIs).

If you really must do this, then you’ll need to automate a call to the API before analysis runs.

Why, you might be wondering, is this so hard?

A: My latest commit isn’t gonna pass the Quality Gate because the business is pushing hard to get these changes into production so I don’t have time to write tests.
B: No problem. Just update the analysis properties in your commit to switch to the ‘Easy Mode’ Quality Gate for this run
A: Yeah! I’ll have to remember to switch it back tho. I’ll do that after lunch.
Narrator: They didn’t remember.

 
HTH,
Ann

I was actually able to get this to work by using PowerShell Invoke-WebRequest