简体   繁体   中英

How can I use Sonar maven plugin to validate local code against Quality Gate?

We have our project integrated with SonarQube remote server, with a Quality Gate configured. Everytime we commit in master our gitlab executes that sonar:sonar and if the code doesnt meet the Quality Gate metrics , the build is rejected.

I would like to do the same in local before pushing to Gitlab.

If I execute sonar:sonar in local pointing to the remote SonarQube server it verifies the Quality Gate and persists the metrics in the server.

But, I would like to do the same without persisting the metrics as it's my own branch. So, if I use -Dsonar.analysis.mode=preview it doesnt persist metrics but it doesnt check the metrics ( Quality Gate )

Is there any way to do it ?

Well, it's not possible to do such a thing yet, as Fabrice said.

I have a similar preview problem at work, so I just put up a local instance of a SonarQube Server in my computer, with all the rules/quality profiles/quality gates as my company.

That way, i can run as many sonar:sonar as i need, testing it locally before the commit, just by specifying the "Dsonar.host.url" parameter.

I don't know if that would solve your problem, but is definitely a way out.

This is not possible, simply because the various conditions checked by a quality gate are usually the result of a complex and comprehensive processing that can be done only by the Compute Engine part of SonarQube.

This is why, currently, plugins like the GitHub Pull Request one only report issues that were found on the piece of code that was modified in the pull request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM