Quality Gates: Shall your projects pass?

by g. ann campbell|

    Editor's Note: This post now contains outdated information. Please read documentation about Quality Gates instead

    With SonarQube 4.3, the concept formerly known as alerts came into its own. No longer, a subset of Quality Profiles (it was always a slightly awkward fit there), the alert concept has grown up and become Quality Gates.

    Quality Gates can be thought of in two different ways. At the practical level, they're collections of what were once called alerts, and are now known simply as "conditions". At the abstract level, they're logic gates, AND-ing together all the conditions in the set to determine whether or not your project can pass.

    On the face of it, this may seem like just a rename and interface shuffle, but it's a bit more than that. By moving gates out of profiles, it means that you can apply exactly the same criteria to all projects, across languages. Sure, you sorta had the ability to do that before, by setting up the same alerts in each profile from language to language. But that was a tedious, manual, and therefore error-prone process. Now you can set it up once and apply it to each project specifically, or set your favorite gate as the default.

    In the area of gates, defaults mostly work the same way they do with profiles: everything gets the default unless specifically assigned to something else. The big difference is that by default, there's no default Quality Gate. (Confused yet?) What I mean is that out of the box, each language has a default profile. It's kinda required for the whole setup to work. But a Quality Gate isn't required for analysis to work out of the box, so at initial startup there's no default Quality Gate.

    SonarQube 4.3 does come with an out-of-the-box gate (it's basically what we use internally), and you can easily make it the default, but we didn't do that for you. Partly because you'll probably want one of your own Quality Gates to be the default. The database migration process moves the alerts from each profile into a new Quality Gate named for the profile and the language it came from.

    So after the upgrade, you'll want to choose a default gate and assign any projects that shouldn't get the default to their specific gates.

    Once you start using 4.3's gates, you'll notice a few visual differences. The icons have been upgraded, and the wording in the renamed "Quality Gate Summary" widget is slightly different:

    Other than that, the experience is much the same as it was, with the highlights on metrics that are keeping your project from passing cleanly through a gate:

    That's pretty much everything you need to know about quality gates. They let the good projects through and block the bad ones. The only question left is: shall your projects pass?