Sonar Qualitygate api 基于严重性 [blocker/critical/major] 而不是类型 [bugs/vulnerability/code-smells]

Sonar Qualitygate api based on Severity [blocker/critical/major] not on Type[bugs/vulnerability/code-smells]

我正在从基于 analysisId 的管道中击中声纳 api (api/qualitygates/project_status?analysisId=xyz)获取项目状态。收到的回复基于 Type[bugs/vulnerability/code-smells]

是否可以根据Severity [blocker/critical/major]获取状态?

{
  "projectStatus": {
    "status": "ERROR",
    "conditions": [
      {
        "status": "OK",
        "metricKey": "bugs",
        "comparator": "GT",
        "errorThreshold": "0",
        "actualValue": "0"
      },
      {
        "status": "ERROR",
        "metricKey": "vulnerabilities",
        "comparator": "GT",
        "errorThreshold": "0",
        "actualValue": "31"
      },
      {
        "status": "ERROR",
        "metricKey": "code_smells",
        "comparator": "GT",
        "errorThreshold": "0",
        "actualValue": "72"
      }
    ],
    "periods": [

    ],
    "ignoredConditions": false
  }
}

这里是我如何获得状态的,可能会帮助那些正在为这个问题而苦苦挣扎的人。

技巧是使用短暂的 branch-name 而不是在 api-[ 之后使用 analysisId =11=]

http://sonardashboard.xxx.com/api/issues/search?componentRoots=<Project-key>&severities=<Type of severity>&branch=<short-lived branch name>

注意:这会产生状态问题 - 打开和关闭。但是无法根据状态使用 api 过滤掉。