BuildBreaker Does not fails in issues and preview mode but fails in publish mode - SonarQube5.6.1

那年仲夏 提交于 2019-12-12 03:03:53

问题


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:


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 ..");


来源:https://stackoverflow.com/questions/40355630/buildbreaker-does-not-fails-in-issues-and-preview-mode-but-fails-in-publish-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!