Deprecated qualitygates/project_status endpoint has no V2 equivalent

Hi,

We use the API v1 qualitygates/project_status to get the quality gate results for a given analysis or pull-request.

This endpoint is marked as deprecated in the API V1 docs, but I can’t find a way to get that data in the V2 docs. Is a replacement endpoint coming, or is there anything way to get this data through the API?

Thanks

Hi,

Welcome to the community!

What’s your CI? For many of them we have a native task to reflect quality gate status back into the pipeline. For everything else, there are webhooks.

 
HTH,
Ann

Hi,

We have the same issue. We can’t use webhooks since our source repositories and build servers are running in-house and IT won’t let them be accessed by external systems. We rely on the qualitygates/project_status endpoint for our pull request process to function correctly, so we’d really like to know what the alternatives are before this endpoint stops functioning.

Thanks

And to answer my own question: you can get the same results as the quality_gates/project_status endpoint, by using the measures/component endpoint and including quality_gate_details in the metric_keys parameter.

e.g.

https://sonarcloud.io/api/qualitygates/project_status?projectKey=yourproject&pullRequest=yourPR

returns

{
  "projectStatus": {
    "status": "OK",
    "conditions": [
      {
        "status": "OK",
        "metricKey": "new_reliability_rating",
        "comparator": "GT",
        "periodIndex": 1,
        "errorThreshold": "1",
        "actualValue": "1"
      },
      {
        "status": "OK",
        "metricKey": "new_security_rating",
        "comparator": "GT",
        "periodIndex": 1,
        "errorThreshold": "1",
        "actualValue": "1"
      },
      {
        "status": "OK",
        "metricKey": "new_maintainability_rating",
        "comparator": "GT",
        "periodIndex": 1,
        "errorThreshold": "1",
        "actualValue": "1"
      },
      {
        "status": "OK",
        "metricKey": "new_coverage",
        "comparator": "LT",
        "periodIndex": 1,
        "errorThreshold": "80",
        "actualValue": "80.8"
      },
      {
        "status": "OK",
        "metricKey": "new_duplicated_lines_density",
        "comparator": "GT",
        "periodIndex": 1,
        "errorThreshold": "3",
        "actualValue": "0.0"
      },
      {
        "status": "OK",
        "metricKey": "new_security_hotspots_reviewed",
        "comparator": "LT",
        "periodIndex": 1,
        "errorThreshold": "100",
        "actualValue": "100.0"
      }
    ],
    "periods": [],
    "ignoredConditions": false
  }
}

https://sonarcloud.io/api/measures/component?component=yourProject&pullRequest=yourPR&metricKeys=quality_gate_details

Will return

{
  "component": {
    "id": "someId",
    "key": "yourProject",
    "name": "someName",
    "description": "some description",
    "qualifier": "TRK",
    "measures": [
      {
        "metric": "quality_gate_details",
        "value": "{\"level\":\"OK\",\"conditions\":[{\"metric\":\"new_reliability_rating\",\"op\":\"GT\",\"period\":1,\"error\":\"1\",\"actual\":\"1\",\"level\":\"OK\"},{\"metric\":\"new_security_rating\",\"op\":\"GT\",\"period\":1,\"error\":\"1\",\"actual\":\"1\",\"level\":\"OK\"},{\"metric\":\"new_maintainability_rating\",\"op\":\"GT\",\"period\":1,\"error\":\"1\",\"actual\":\"1\",\"level\":\"OK\"},{\"metric\":\"new_coverage\",\"op\":\"LT\",\"period\":1,\"error\":\"80\",\"actual\":\"80.8\",\"level\":\"OK\"},{\"metric\":\"new_duplicated_lines_density\",\"op\":\"GT\",\"period\":1,\"error\":\"3\",\"actual\":\"0.0\",\"level\":\"OK\"},{\"metric\":\"new_security_hotspots_reviewed\",\"op\":\"LT\",\"period\":1,\"error\":\"100\",\"actual\":\"100.0\",\"level\":\"OK\"}],\"ignoredConditions\":false}"
      }
    ],
    "pullRequest": "yourPR"
  }
}

The value reads

{
  "level": "OK",
  "conditions": [
    {
      "metric": "new_reliability_rating",
      "op": "GT",
      "period": 1,
      "error": "1",
      "actual": "1",
      "level": "OK"
    },
    {
      "metric": "new_security_rating",
      "op": "GT",
      "period": 1,
      "error": "1",
      "actual": "1",
      "level": "OK"
    },
    {
      "metric": "new_maintainability_rating",
      "op": "GT",
      "period": 1,
      "error": "1",
      "actual": "1",
      "level": "OK"
    },
    {
      "metric": "new_coverage",
      "op": "LT",
      "period": 1,
      "error": "80",
      "actual": "80.8",
      "level": "OK"
    },
    {
      "metric": "new_duplicated_lines_density",
      "op": "GT",
      "period": 1,
      "error": "3",
      "actual": "0.0",
      "level": "OK"
    },
    {
      "metric": "new_security_hotspots_reviewed",
      "op": "LT",
      "period": 1,
      "error": "100",
      "actual": "100.0",
      "level": "OK"
    }
  ],
  "ignoredConditions": false
}

which appears to be identical to the projectStatus in the deprecated endpoint’s response