Thanks Ann for sharing details about metrics confusion. I completely agree with that however the original issue I am seeking help with is a different issue. Sorry if that was not clear.. Let me clarify the original issue:
Background:
Sonarqube has a web interface to create condition where we can create all kinds of metrics including maintainability/reliability/security rating for a quality gate.
Sonarqube also has an api to do the same (create quality gate condition) at endpoint: /api/qualitygates/create_condition. The documented description for which is:
{
"key": "create_condition",
"description": "Add a new condition to a quality gate.<br>Requires the 'Administer Quality Gates' permission.",
"since": "4.3",
"internal": false,
"post": true,
"hasResponseExample": true,
"changelog": [],
"params": [
{
"key": "error",
"description": "Condition error threshold",
"required": false,
"internal": false,
"exampleValue": "10",
"maximumLength": 64
},
{
"key": "gateId",
"description": "ID of the quality gate",
"required": true,
"internal": false,
"exampleValue": "1"
},
{
"key": "metric",
"description": "Condition metric",
"required": true,
"internal": false,
"exampleValue": "blocker_violations"
},
{
"key": "op",
"description": "Condition operator:<br/><ul><li>EQ = equals</li><li>NE = is not</li><li>LT = is lower than</li><li>GT = is greater than</li></ui>",
"required": false,
"internal": false,
"exampleValue": "EQ",
"possibleValues": [
"LT",
"GT",
"EQ",
"NE"
]
},
{
"key": "organization",
"description": "Organization key. If no organization is provided, the default organization is used.",
"since": "7.0",
"required": false,
"internal": false,
"exampleValue": "my-org"
},
{
"key": "period",
"description": "Condition period. If not set, the absolute value is considered.",
"required": false,
"internal": false,
"possibleValues": [
"1"
]
},
{
"key": "warning",
"description": "Condition warning threshold",
"required": false,
"internal": false,
"exampleValue": "5",
"maximumLength": 64
}
]
}
Issue:
I can use web interface to create maintainability/reliability/security rating but I can't use api to do the same. I can use api to create other metrics e.g. maintainability on new code etc..but can 't create maintainability/reliability/security rating.
If I try to create api, I get 400 (bad request) with following messages, based on request data (you can also see in screenshots attached in first post):
request data: [{op=[GT], period=[1], metric=[sqale_rating], gateId=[6], warning=[], error=[1]}]
response code: 400
response message: The metric 'Maintainability Rating' cannot be used on the leak period
request data: [{op=[GT], period=[0], metric=[sqale_rating], gateId=[6], warning=[], error=[1]}]
response code: 400
response message: Value of parameter 'period' (0) must be one of: [1]
Now I am not sure what data should I send to endpoint /api/qualitygates/create_condition in request to create Maintainability/Reliability/Security rating. Can you please help me with that.
Thanks a lot,
Kumar