Set up PR Gate Rules

This product is not supported for your selected Datadog site. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Join the Preview!

PR Gates are in Preview.

Overview

To use Datadog PR Gates, you can define one or more rules on the PR Gate Rules page.

PR Gates page in Datadog

PR Gates ensure that only the code that meets your quality standards is deployed, automating your quality assurance processes and enhancing software reliability.

Create a rule

To create a PR Gates rule in Datadog:

  1. Navigate to Software Delivery > PR Gates > PR Gate Rules and click New Rule.

  2. Under Select your source, select a rule type:

    • Static Code Analysis
    • Software Composition Analysis
    • Code Coverage
    • Infrastructure as Code Scanning
  3. Under Define condition, set the conditions that will cause the rule to fail, which also fails the related pipeline. Each rule type has its own condition options, and you can use the existing default condition settings when you select a rule type.

  4. Under Define scope, set which repositories the rule should evaluate:

    • All repositories: The rule evaluates all repositories configured for the rule type.
    • Selected repositories: The rule evaluates only the repositories you specify. Use IN to include only specified repositories, or NOT IN to evaluate all configured repositories except the ones you specify.

    The following example illustrates a Static Code Analysis rule that fails when a pull request introduces at least one Static Code Analysis code vulnerability violation with at least Critical severity. The rule evaluates all repositories configured for Static Code Analysis:

    A Static Analysis rule that runs on all repos and fails when a PR has at least one Static Code Analysis code vulnerability with at least `Critical` severity
  5. Under Preview checks, select your CI provider to preview the status check to be added to pull requests. To set the check so it blocks the pipeline when it fails, follow your provider’s instructions for making a status check required:

    Non-blocking rules can be helpful when you roll out a new rule and want to verify its behavior before making it blocking.

  6. Click Create Rule.

Manage PR checks

PR Gates automatically create PR checks in GitHub or Azure DevOps pull requests for each rule type evaluated. The check contains additional information about the rule evaluation, such as the failure reason and the matching events in Datadog.

Note: Re-running a check in the pull request UI does not re-run the corresponding PR Gates rule.

To ensure PR Gates are able to create PR checks, you must install the integration for your SCM provider. If you do not have the integration installed, follow the GitHub or Azure DevOps Source Code integration documentation to set one up.

Manage rules

You can edit or delete a PR Gates rule by hovering over it on the PR Gates Rules list and clicking the Edit or Delete icon.

Edit, clone, or delete a PR Gates rule

Permissions

Only users with the quality_gate_rules_write permission can create and edit PR Gate rules. Users with the quality_gate_rules_read permission can view PR Gate rules.

For more information, see the RBAC Permissions documentation.

Further reading

Documentation, liens et articles supplémentaires utiles: