0

I am using Buildbreaker2.4 plugin in sonarQube5.6.1.

When i run the below command,

mvn sonar:sonar -Dsonar.issuesReport.html.enable=true -Dsonar.analysis.mode=publish

Buildbreaker fails with critical issues

But when i run any of the below two commands, it gets passed.

mvn sonar:sonar -Dsonar.issuesReport.html.enable=true -Dsonar.analysis.mode=issues
mvn sonar:sonar -Dsonar.issuesReport.html.enable=true -Dsonar.analysis.mode=preview

Suggest me on what might be the problem.

Syed
  • 61
  • 2
  • 10
  • 1
    SonarQube posted [this](http://www.sonarqube.org/why-you-shouldnt-use-build-breaker/) article. Is seems the support for Buildbreaker stopped after version [5.4](http://docs.sonarqube.org/display/SONARQUBE54/Breaking+the+CI+Build). – Jeroen Heier Nov 02 '16 at 05:18
  • So what is the alternate for this? i mean if quality gate fails somehow my first command fails, But i want it to fail in preview mode as well – Syed Nov 02 '16 at 05:35

1 Answers1

0

for fail in preview mode you have to write your plugin '@batchside' (implements PostJob).

1- load current quality gate properties for your project

WsRequest wsRequest = new GetRequest("api/qualitygates/show").setParam("id", qgId).setMediaType(MediaTypes.PROTOBUF);


2- read errors of your current analysis (in PostJobContext object)

Iterator<PostJobIssue> iterator = context.issues().iterator();


3- do your business, compare errors and thresold of your QG
4- finish in a exception and it will break the 'preview' build

 throw MessageException.of("too many errors for preview mode ..");
Maxence Lecointe
  • 238
  • 5
  • 11