Get a List of Quality Gates

DescriptionGet a list of quality gates

URL

/api/qualitygates/list

HTTP MethodGET
Response Formatsjson

Security

None
Available sinceVersion 4.3

Examples

Use Case

Example Request

Get all the quality gates

GET http://localhost:9000/api/qualitygates/list

Response Format

{
  "qualitygates":
    [
      {
        "id":2,
        "name":"QG1"
      },
      {
        "id":4,
        "name":"QG2"
      },
      ...
    ]
}

Parameters

None

Display the Details of a Quality Gate

DescriptionDisplay the details of a quality gate

URL

/api/qualitygates/show

HTTP MethodGET
Response Formatsjson

Security

None
Available sinceVersion 4.3

Examples

Use Case

Example Request

Display the details of quality gate 1

GET http://localhost:9000/api/qualitygates/show?id=1

Response Format

{
  "id":2,
  "name":"My Quality Gate",
  "conditions":
    [
      {
        "id":9,
        "metric":"blocker_violations",
        "op":"GT",
        "error":"0"
      },
      {
        "id":10,
        "metric":"critical_violations",
        "op":"GT",
        "warning":"0"
      },
      ...
    ]
}

Parameters

Parameter

Description

Required

Default Value

Example Value

id

ID of the quality gate

Either id or name must be set

None

1

name

Name of the quality gate

Either id or name must be set

None

My Quality Gate

Create a Quality Gate

DescriptionCreate a Quality Gate

URL

/api/qualitygates/create

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Create a quality gate

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/create?name=QG1"

Parameters

Parameter

Description

Required

Default Value

Example Value

name

Name of the quality gate to create

Yes

None

My Quality Gate

Delete a Quality Gate

DescriptionDelete a Quality Gate

URL

/api/qualitygates/destroy

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Delete quality gate 1

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/destroy?id=1"

Parameters

Parameter

Description

Required

Default Value

Example Value

id

ID of the quality gate to delete

Yes

None

1

Copy a Quality Gate

DescriptionCopy a Quality Gate

URL

/api/qualitygates/copy

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Make a copy of quality gate 1: "QG1"

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/copy?id=1&name=QG1"

Rename a Quality Gate

DescriptionRename a Quality Gate

URL

/api/qualitygates/rename

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Rename quality gate 1 into "QG2"

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/rename?id=1&name=QG2"

Parameters

Parameter

Description

Required

Default Value

Example Value

id

ID of the quality gate to rename

Yes

None

1

name

New name of the quality gate

Yes

None

My Quality Gate

Set a Quality Gate as the Default Quality Gate

DescriptionSet a quality gate as the default quality gate

URL

/api/qualitygates/set_as_default

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Set quality gate 1 as the default quality gate

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/select_as_default?id=1"

Parameters

Parameter

Description

Required

Default Value

Example Value

id

ID of the quality gate to set as default

Yes

None

1

Unset a Quality Gate as the Default Quality Gate

DescriptionUnset a quality gate as the default quality gate

URL

/api/qualitygates/unset_default

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Unset quality gate 1 as the default quality gate

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/unset_default?id=1"

Parameters

Parameter

Description

Required

Default Value

Example Value

id

ID of the quality gate to unset as default

Yes

None

1

Add a New Condition to a Quality Gate

DescriptionAdd a new condition to a quality gate

URL

/api/qualitygates/create_condition

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Add a condition to quality gate 1

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/create_condition?gateId=1&metric=blocker_violations&op=GT&warning=0&error=5"

Parameters

Parameter

Description

Required

Default Value

Example Value

gateId

ID of the quality gate

Yes

None

1

metric

Contition metric

Yes

None

blocker_violations

op

Condition operator

Possible values: EQ | NE | LT | GT.

EQ = equals
NE = is not
LT = is lower than
GT = is greater than 

No

None

GT

period

Condition period

No

None

1

error

Condition error threshold

No

None

10

warning

Condition warning threshold

No

None

5

Update a Condition

DescriptionUpdate a condition

URL

/api/qualitygates/update_condition

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Update condition 10

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/update_condition?gateId=1&metric=blocker_violations&op=GT&warning=0&error=5"

Parameters

Parameter

Description

Required

Default Value

Example Value

id

Condition ID

Yes

None

10

metric

Contition metric

Yes

None

blocker_violations

op

Condition operator

Possible values: EQ | NE | LT | GT.

EQ = equals
NE = is not
LT = is lower than
GT = is greater than 

No

None

GT

period

Condition period

No

None

1

error

Condition error threshold

No

None

10

warning

Condition warning threshold

No

None

5

Delete a Condition from a Quality Gate

DescriptionDelete a condition from a quality gate

URL

/api/qualitygates/delete_condition

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Delete condition 2 from quality gate 1

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/delete_condition?id=2"

Parameters

Parameter

Description

Required

Default Value

Example Value

id

Condition ID

Yes

None

2

Associate a Project to a Quality Gate

DescriptionAssociate a project to a quality gate

URL

/api/qualitygates/select

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Associate project 12 to quality gate 1

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/select?gateId=1&projectId=12"

Parameters

Parameter

Description

Required

Default Value

Example Value

gateId

Quality Gate ID

Yes

None

1

projectId

Project ID

Yes

None

12

Remove the Association of a Project from a Quality Gate

DescriptionRemove the association of a project from a quality gate

URL

/api/qualitygates/deselect

HTTP MethodPOST

Security

Administer Quality Profiles and Gates
Available sinceVersion 4.3

Examples

Use Case

Example Request

Remove association of project 12 from quality gate 1

curl -u admin:admin -X POST "http://localhost:9000/api/qualitygates/deselect?gateId=1&projectId=12"

Parameters

Parameter

Description

Required

Default Value

Example Value

gateId

Quality Gate ID

Yes

None

1

projectId

Project ID

Yes

None

12

Search for Projects Associated (or not) to a Quality Gate

DescriptionSearch for projects associated (or not) to a quality gate

URL

/api/qualitygates/search

HTTP MethodPOST

Security

None
Available sinceVersion 4.3

Examples

Use Case

Example Request

Search for projects associated to quality gate 1. Two results per page, display page 1.

GET http://localhost:9000/api/qualitygates/search?gateId=1&pageSize=2&page=1

Response Format

{
  "more":true,
  "results":
    [
      {
        "id":1,
        "name":"Simple Java project analyzed with the SonarQube Runner",
        "selected":true
      },
      {
        "id":4,
        "name":"My Project",
        "selected":true
      }
    ]
}

Parameters

Parameter

Description

Required

Default Value

Example Value

gateId

Quality Gate ID

Yes

None

1

query

To search for projects containing this string

No

None

abc

page

Page number

No

0

2

pageSize

Page size

No

None

10

selected

If "selected", search for projects associated to the quality gate.

Possible values: selected | deselected

No

selected

deselected