BuildBreaker Does not fails in issues and preview

2019-09-14 11:26发布

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.

1条回答
何必那么认真
2楼-- · 2019-09-14 12:21

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 ..");
查看更多
登录 后发表回答