Checks

Checks define what is validated within a rule. They enforce specific compliance requirements, such as validating Jira issues, ensuring correct naming conventions, or verifying the presence and consistency of issue keys. Checks are executed only when a rule is triggered and its conditions are met. As a result, they form the core validation logic within the system.

Checks are executed against the selected Validation Targets. Depending on the rule configuration, validations can be performed against commits, branch names, pull request titles, pull request descriptions, or the files a pull request changes.

A rule may use a single check or combine multiple checks. This allows teams to create simple validations or more advanced compliance policies within a single rule.

Issue checks

The issue check validates the presence, validity, consistency, and compliance of Jira issue references. It ensures that commits, branches, pull request titles, and pull request descriptions reference valid Jira issues and, when required, consistently point to the same work item.

The check can verify that issue keys exist, that they can be resolved in Jira, and that the referenced issues satisfy additional requirements through configurable JQL queries. This allows teams to enforce workflow policies directly from Jira, such as requiring specific issue statuses, issue types, projects, or custom field values before changes can progress through the development workflow.

By enforcing valid and consistent issue references, the issue check strengthens the relationship between code changes and tracked work. This improves traceability, reduces ambiguity, and creates a reliable audit trail that allows teams to understand why changes were made, which Jira issues they relate to, and whether all governance requirements were satisfied at the time of validation.

issue-checks.png

Configuration options

  • Require issue consistency - When enabled, all issue keys found within the selected validation targets must reference the same Jira issue. This check is useful when commits, branches, pull request titles, or pull request descriptions are expected to refer to the same work item.

  • Require valid issue keys - When enabled, each selected validation target must contain at least one valid Jira issue key. Detected issue keys are validated against Jira to ensure that they exist and can be resolved successfully.

  • Require JQL match - When enabled, all detected Jira issues are validated against the configured JQL query. This allows teams to enforce workflow requirements directly from Jira, such as issue status, issue type, project membership, sprint assignments, or custom field values.

The Issue validation strategy determines how multiple issue keys or JQL checks within the same validation target are evaluated.

  • All: All detected issue keys within the target must be valid Jira issues (or match the JQL).

  • One: At least one detected issue key within the target must be a valid Jira issue (or match the JQL).

Key takeaway

The issue check ensures that code changes are linked to valid Jira issues and, when required, consistently reference the same work item across commits, branches, and pull requests. By validating issue existence, consistency, and JQL compliance, it improves traceability, enforces workflow requirements, and strengthens the overall audit trail of the development process.

Naming convention check

The naming convention check validates naming standards across branches, commits, and pull requests. It ensures that all names and messages follow defined patterns, typically based on regular expressions.

Configuration options

Option name

Description

Branch name

Defines the naming rules for branch names. This option is used to enforce a consistent branch structure, for example by requiring a specific prefix, the location of an a Jira issue key, or another repository-specific naming pattern.

Commit messages

Defines the rules for commit messages. This option is used to enforce a consistent commit message format, for example by requiring a Jira issue key, a structured prefix, or a predefined message pattern.

Pull request titles

Defines the naming rules for pull request titles. This option helps enforce a consistent and traceable title format across pull requests.

Pull request descriptions

Defines the content rules for pull request descriptions. This option can be used to require a certain structure, mandatory information, or a specific text pattern in the description.

Each naming option can contain one or multiple regular expressions. If multiple expressions are configured, the matching strategy defines how they are evaluated:

  • All: All configured regular expressions must match

  • One: At least one configured regular expression must match

See Pattern syntax for the supported syntax.

User interface

The following screenshot shows how to configure the naming convention check:

naming.png

Key takeaway

The naming convention check enforces consistent standards across the workflow.

File approval check

The file approval check reacts when a pull request changes certain files, for example the build pipeline or the payment code. Pull requests that change none of these files are not affected. When a changed file matches, the rule can do two things, separately or together:

  • Add the selected users as reviewers: the selected people are added as reviewers of the pull request, so Bitbucket notifies them right away.

  • Require a number of approvals from the selected users before merging: the pull request cannot be merged until enough of the selected people have approved it, for example 2 of the 3 owners of the payment code.

Both together are the usual setup for owners of sensitive files. Adding reviewers alone keeps people informed without blocking the merge.

The check runs for pull requests only. Select the trigger Pull Request and the validation target Changed files; see Target.

The quickest way to set up a file approval is Create → APPROVAL in the rule list. It opens a new rule with the trigger Pull Request, the validation target Changed files, and the file approval check turned on; you only add the file paths and select the people.

A rule protects one set of files. To protect other files with other people, create one rule for each.

How it works

  1. The check reads the files the pull request changes. For renamed and deleted files, the old path counts as well.

  2. The rule applies when at least one changed file matches one of its file paths.

  3. With Add the selected users as reviewers when the pull request is created, the app adds the selected users and, if selected, all repository administrators as reviewers when the pull request is created, and also when a later update changes a matching file. It only adds reviewers and never removes anyone. The author of the pull request is never added.

  4. With Require a number of approvals from the selected users before merging, the rule is satisfied when the number of Required approvals is reached. Approvals of the selected users and repository administrators count together; each person counts once. Until then, the merge is blocked. Without it, the rule is always satisfied.

If the changed files or the approvers cannot be determined, for example because Bitbucket does not respond, the check blocks the merge instead of letting the pull request pass.

Configuration options

Option

Description

Values

File approval

Turns the check on for the rule.

On, off

File paths

The files the rule protects. The rule applies if at least one changed file matches.

Regular expressions matched against the full path of each changed file, for example ^bitbucket-pipelines\.yml$ or ^src/payment/; see

Pattern syntax

Users

The people the rule is about: who is added as reviewer and who may approve.

One or more Bitbucket users

Repository administrators

Selects everyone with admin permission on the repository as well, whether the permission is granted directly, through a group, or as workspace administrator.

Selected, not selected

Add the selected users as reviewers when the pull request is created

Adds the selected users and, if selected, the repository administrators as reviewers, so Bitbucket notifies them. In repositories with many administrators, this notifies many people.

Selected, not selected

Require a number of approvals from the selected users before merging

Blocks the merge until the required approvals are given.

Selected (default), not selected

Required approvals

How many approvals are needed. Only with Require a number of approvals from the selected users before merging.

1 or more, default 1; without repository administrators at most the number of users

Select at least one user or Repository administrators, and at least one of Add the selected users as reviewers when the pull request is created and Require a number of approvals from the selected users before merging.

Below the options, the Summary says in one sentence what the rule does, for example "The 2 selected users are added as reviewers when the pull request is created or a later update changes a matching file. Merging is blocked until 2 approvals from the 2 selected users are given." Select Dismiss to hide it for now, or Do not show again to hide it for good.

Groups as approvers

Bitbucket groups cannot be selected as approvers yet. Bitbucket Cloud does not currently provide group membership to apps through its supported REST API. Support for groups is planned as soon as Bitbucket Cloud makes it possible. Until then, select the users individually, or select Repository administrators and give the group admin permission on the repository.

The payment code needs two approvals; both owners are added as reviewers:

File approval with reviewers and two required approvals

The technical writer is added as reviewer to documentation changes, without blocking the merge:

File approval that only adds a reviewer

Bitbucket's own setting for resetting approvals when the source branch changes decides whether an approval still counts after new commits. The check uses the approvals that Bitbucket shows at the time of the check. Authors cannot approve their own pull requests in Bitbucket, so their approval never counts. If an author is one of two selected users and two approvals are required, the rule cannot be satisfied in their pull request.

Use a separate rule for file approvals

If a rule combines the validation target Changed files with other targets and uses the strategy At least one target must be valid, one valid other target is enough for the rule to pass. The pull request can then be merged without the required file approval. The rule dialog shows a warning for this combination but saves it, and configuration as code accepts it as well. To make an approval mandatory, put the file approval check into a rule of its own with the target Changed files only.

Result in the pull request

The pull request card shows the result in the section Changed files: the changed files, how many of the required approvals are given, and from whom they are still needed. For a rule that only adds reviewers, it names the users who were added.

Changed files section with one of two approvals

To protect the build pipeline with one click, use the template Protected pipeline; see Templates.

Key takeaway

The file approval check makes sure that the owners of sensitive files, such as the build pipeline or infrastructure code, approve every change to them before it is merged, and that the right people are added as reviewers.

Pattern syntax

All patterns in rules are regular expressions: the branch, file path, naming convention, and issue key patterns in conditions and checks. They are evaluated with an engine whose matching time grows linearly with the length of the input, so even very long branch names, file paths, and messages are checked reliably.

The common regular expression syntax is supported:

  • character classes, such as [A-Z], [^#\n]

  • groups, including named groups (?<name>...), and alternation |

  • quantifiers *, +, ?, {n,m}, including lazy ones such as *?

  • anchors ^, $, and \b

  • the classes \d, \w, and \s

  • \uXXXX escapes and inline flags such as (?i)

The following constructs are not supported:

  • lookahead (?=...) and negative lookahead (?!...)

  • lookbehind (?<=...) and negative lookbehind (?<!...)

  • backreferences \1 to \9 and \k<name>

  • atomic groups (?>...)

  • possessive quantifiers *+, ++, and ?+

Two minor differences: . matches every character except a line feed, which includes a carriage return, and \s matches ASCII whitespace only.

The rule dialog and the Process Guardian settings reject an unsupported pattern when you save, with the message Invalid regular expression.

Existing rules with unsupported patterns

A rule that is already stored, or that comes from configuration as code, and contains an unsupported pattern is treated like a rule with an invalid pattern: the naming convention checks for branches and pull requests, branch conditions, and the file approval check fail, so the rule blocks; the naming convention check for commit messages ignores the pattern; and the changed files condition never matches it. Rewrite these patterns.

Typical rewrites:

Before

After

One pattern with a length limit, (?=.{20,100}$)X

Two patterns, ^.{20,100}$ and X, with the strategy All

Text without a character, ((?!#).)*

[^#\n]*

Next steps

Conditions define when a rule applies. Use conditions to restrict rules to specific contexts, for example certain branches, users, or pull request flows, so that validation is only executed where it is relevant.