Quality gate is the maximum number of problems that can be detected by Qodana without causing a CI/CD workflow or pipeline fail. Once the quality gate limit is reached, Qodana terminates with the exit code 255.
This feature lets you control your code quality and build software that meets your quality metrics. For example, if you set the quality gate for ten problems, a build workflow will fail once the eleventh problem is detected.
The quality gate and fail threshold terms are used interchangeably with the former being a feature in overall, and the latter meaning a configuration option.
This section explains how to configure Qodana quality gate for:
You can run Qodana with the configured quality gate locally using available Docker images:
In this sample,
<source-directory> specifies the full local path to the project source code, and the
--fail-threshold <number> option configures the quality gate.
You can enforce GitHub to block merge of pull requests if the Qodana quality gate has failed. To do it, create a branch protection rule as described below:
Create a new or open an existing GitHub Actions workflow that invokes the Qodana scan action.
Set the workflow to run on
pull_requestevents that target the
mainbranch.on: pull_request: branches: - main
main, you can specify your branch here.
Set the fail threshold (number) for the Qodana Action
Under your repository name, click.
On the left menu, click.
In the branch protection rules section, click.
Search for thestatus check, then check it.
To set up Qodana quality gate in a Jenkins Pipeline, you can add the
--fail-threshold <number> option to the
To learn more about Qodana integration with Jenkins, see the Jenkins integration section of this documentation.
To configure the Qodana quality gate in a GitLab CI/CD pipeline, you can save this configuration sample to the
In this sample, the
script section specifies the
--fail-threshold <number> option.