Search code examples
sonarqube

Let quality gate violation fail incremental analysis


We're trying to set up a pull-request build pipeline that is triggered from Bitbucket, reports back failure when Sonarqube's code analysis reports some quality gate violation and ultimatively rejects the PR.

As far as I have read, the build breaker plugin, that should enable such a thing, is no longer supported in the most recent versions of Sonarqube, at least not in incremental / preview modes, since they now work database-less.

What are my alternatives for creating such a functionality? Sticking with 5.0?

Also, I figured that since quite some time Sonarqube can spit out Text / HTML reports for CI analysis - does this output quality gate violations as well or only all individual inspection results? Should one retrieve the former via API then? But I suspect this would require a full analysis, since it requires the results to be saved to the database, right?


Solution

  • There are two Bitbucket-related plugins to analyze pull requests. One for On Demand/Cloud and one for Server. Each will add comments to your pull request, and the On Demand version will approve a PR with no new issues.

    Regarding your second question, the Issue Reports you're referring to contain only issues. In fact, it's not possible to calculate general Quality Gate compliance from a preview/incremental analysis since such analyses look only at issues, and Quality Gates can contain conditions on tests, duplications, &etc.