How to create conditions on overall code instead of new code over API?

Hi all,

I am trying to develop a configuration as code script for my Sonarqube infrastructure. I am currently running the Enterprise version.

I red the WebAPI doc’s and I am trying to understand how you can choose on where to set the new condition.
By default every new condition I create or delete is made on new code.
What If I want to add a condition to the overall code?

Hey there.

You’ll notice in our metric definitions that some metrics are prefixed with new_ – and those are the metrics that are applied only on new code. Those without new_ are applied on overall code.

Hi Colin,
thanks for the info. I wasn’t sure about that. Wasn’t that clear for me at first sight.

I got another question regarding the conditions. I see I can only delete a condition based on the id.
Why is it not possible to define the quality gate and condition name instead?

In all honesty, probably a design decision that dates back more than a decade (SONAR-4366). Probably it would be designed differently if it was built today!

It does mean that you’ll have to call GET api/qualitygates/show to retrieve the condition ID first.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.