Sonargraph-Build can be used to enforce quality gates. All that is needed is a failSet configuration including the issue type "QualityGateIssue". The example below shows the XML configuration file for the shell integration of Sonargraph-Build. The same options exist for the other integrations (Ant, Maven, Gradle):
<sonargraphBuild ... <failSet> <failOnEmptyWorkspace>false</failOnEmptyWorkspace> <includes> <include> <issueType>QualityGateIssue</issueType> </include> </includes> </failSet> </sonargraphBuild>
The result of the quality gate check is printed to the console (slightly formatted here):
...
Checking active quality gate(s)...
[Failed] Quality Gate 'No_Additional_CycleGroups'
[Failed] Baseline Conditions:
[Failed] Condition "Change of metric value for 'Core:System:CyclicComponents' must be
<= 1,00 (absolute)" [0 -> 2 (+2)]
[Failed] Condition "Change of metric value for 'Java:System:CyclicityPackages' must be
<= 1,00 (absolute)" [0 -> 4 (+4)]
[Failed] Quality Gate 'No_Threshold_Violations'
[Failed] Current System Conditions:
[Failed] Condition "<= 0 threshold violations for metric 'Core:Type:SourceElementCount'
with severity 'Any' and resolution 'None'" [5 issues matched (0 excluded)]
[Passed] Condition "<= 0 issues of type 'ThresholdViolation'
with severity 'Error' and resolution 'None'" [0 issues matched (0 excluded)]
[Passed] Baseline Conditions:
[Passed] Condition "No additional or worsened threshold violations for metric
'Core:Type:SourceElementCount' with severity 'Any' and resolution 'None'"
[0 issues matched (0 excluded, 0 tolerated)]
Check of quality gates failed.
Quality Gate Summary: 2 of 2 failed.
...
