简体   繁体   中英

Sonarqube: How to get the id of quality gate

I have several quality gates created within sonarqube and I would like to know how to obtain the ids of each of them

I would first urge you to step back and describe exactly what you need to get done.

However, you can get information about quality gates and other SonarQube components from the WebAPI rest interface. Go into your SonarQube gui, go to the bottom of the page, and click on the "Web API" link. Enter "quality gate" in the filter to see information about all of the endpoints related to quality gates.

On the official documentation you can find following methods:

GET api/qualitygates/get_by_project

Get the quality gate of a project.
Requires one of the following permissions:
- 'Administer System'
- 'Administer' rights on the specified project
- 'Browse' on the specified project

ParametersResponse 
{
  "qualityGate": {
    "id": "AU-Tpxb--iU5OvuD2FLy",
    "name": "My team QG",
    "default": false
  }
}

and

GET api/qualitygates/list

Get a list of quality gates
Response
{
  "qualitygates": [
    {
      "id": "AU-Tpxb--iU5OvuD2FLy",
      "name": "Sonar way",
      "isDefault": true,
      "isBuiltIn": true,
      "actions": {
        "rename": false,
        "setAsDefault": false,
        "copy": true,
        "associateProjects": false,
        "delete": false,
        "manageConditions": false
      }
    },
    {
      "id": "AU-Tpxb--iU5OvuD2FLz",
      "name": "Sonar way - Without Coverage",
      "isDefault": false,
      "isBuiltIn": false,
      "actions": {
        "rename": true,
        "setAsDefault": true,
        "copy": true,
        "associateProjects": true,
        "delete": true,
        "manageConditions": true
      }
    }
  ],
  "default": 8,
  "actions": {
    "create": true
  }
}

Both of these methods will return ids.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM