Add new metrics Quality Gates by Ansible

Hello, I have a question I’m using Sonarqube 7.9.1 and I have scripted by ansible creation of Quality Gates and I have add new metrics by using API like this for example:

  • “error=0&metric=blocker_violations&op=GT&gateId={{ }}”

But what are the condition to use for metrics:

  • Maintainability Rating on New Code
  • Security Rating on New Code

And the operator “is worse”. I have found nothing on documentations.

Thank you.

Hi Sullivan,

Welcome to the community!

There’s a web service to list all the metrics: api/metrics/search (you may need to paginate this or set a high page size). For each metric it returns both the key and the pretty name. If the metric is qualitative, then its direction will indicate which way is “worse” (altho TBH, I don’t remember how 1 and -1 decode).


Thank you for you quick answer.

I have found two metrics with the list thank you. But I don’t find how to use the operator “is worse than”, with other metrics like example in my first post when “is greater than” I use “op=GT” and when “is less than” I use “op=LT”, but for “is worse than” I don’t find what I have to use.


Your best bet here is to make the change through the UI and use your Developer Tools to watch what your browser sends.