Conditions define when a rule applies. They act as a filter before any validation starts. A rule is only evaluated when its trigger fires and all configured conditions are satisfied. This allows teams to apply rules selectively based on context, such as branch patterns.
Conditions can be added to an existing rule to control in which situations that rule should be evaluated.
Pull request condition
The pull request condition controls whether a rule applies based on pull request information.
It is used to restrict rule execution to specific pull request flows by evaluating the destination branch. This makes it possible to target rules to defined integration paths, such as merges into release branches, main branches, or other controlled target branches. By applying rules only where they are relevant, the pull request condition helps reduce unnecessary validations and supports more precise compliance enforcement.
Configuration options
|
Option name |
Description |
Values |
|---|---|---|
|
Destination branch |
Defines conditions for the pull request target branch. |
|
Branch condition
The branch condition controls whether a rule applies based on the current branch name.
It is used to restrict rule execution to specific branches by evaluating the branch against configured include and exclude patterns. This makes it possible to target rules to defined branch types, such as feature branches, bugfix branches, release branches, or other repository-specific workflows.
By applying rules only where they are relevant, the branch condition reduces unnecessary validations and enables more precise compliance enforcement.
The branch condition is evaluated for Commit, Push, and Pull Request validations. The branch that is evaluated depends on the trigger and context:
-
For Commit validations, the current branch is evaluated.
-
For Push validations, the branch being pushed is evaluated.
-
For Pull Request validations, the branch condition is evaluated against the source branch of the pull request.
As a result, the same branch condition can be reused consistently across different stages of the development workflow.
|
Option name |
Description |
Values |
|---|---|---|
|
Branch |
Defines conditions for the pull request source branch. |
|
Pattern matching strategy
Each include and exclude condition can contain one or multiple regular expressions. If multiple include patterns are configured, the pattern matching strategy defines whether:
-
All patterns must match
-
At least one pattern must match
See Pattern syntax for the supported regular expression syntax.
Examples:
|
Branch |
Destination branch |
Result Push |
Result Pull |
|---|---|---|---|
|
feature/login |
release/1.0.x |
Executed Branch does match the configured include pattern (feature/.*) |
Executed Source branch matches an include pattern (^feature/.*) and destination branch matches an include pattern (release/.*). |
|
bug/login |
release/1.0.x |
Executed Branch does match the configured include pattern (bug/.*) |
Executed Source branch matches an include pattern (^bug/.*) and destination branch matches an include pattern (release/.*). |
|
feature/login |
feature/backend |
Executed Branch does match the configured include pattern (feature/.*) |
Skipped Destination branch matches an exclude pattern (feature/.*). (at least one) |
|
feature/login |
bug/backend |
Executed Branch does match the configured include pattern (feature/.*) |
Skipped Destination branch matches an exclude pattern (bug/.*). (at least one) |
|
release/1.0.x |
release/1.0.x |
Skipped Branch does match the configured exclude pattern (release/.*). |
Skipped Source branch matches an exclude pattern (release/.*) |
|
feature/login |
main |
Executed Branch does match the configured include pattern (feature/.*) |
Skipped Destination branch does not match the configured include pattern (release/.*). |
|
develop |
release/1.0.x |
Skipped Branch does not match the configured include pattern
|
Skipped Source branch does not match any configured include pattern
|
Changed files condition
The changed files condition controls whether a rule applies based on the files a pull request, a commit, or a push changes.
It is used to run a rule only for changes to certain files, for example a documentation check only when files under docs/ change, or to skip a rule for changes to certain files. The file paths are matched with regular expressions, in the same way as branch names in the branch condition. See Pattern syntax for the supported syntax.
To set it up, open Compliance Rules, select Conditions next to the rule, and choose Changed files. The dialog Changed files condition opens.
|
Option |
Description |
Values |
|---|---|---|
|
Include file paths |
The rule is only executed if at least one changed file path matches. |
Regular expressions; from two patterns on, the Pattern matching strategy |
|
Exclude file paths |
The rule is skipped if at least one changed file path matches, unless the include file paths match. |
Regular expressions; from two patterns on, the Pattern matching strategy |
The changed files condition is evaluated like the branch condition, with the changed files in place of the branch name:
-
A pattern matches if at least one changed file path matches it. For a renamed file, the old and the new path count; for a deleted file, its path.
-
With All patterns must match, every pattern must match a changed file; with At least one pattern must match, one pattern is enough. A new include starts with At least one pattern must match.
-
If Include file paths is switched on, it alone decides: when it matches, the rule is executed even if excluded files changed, because include conditions override exclude conditions. Use Exclude file paths on its own to skip a rule for certain files.
Commits and pushes
For local commit and push checks, the Git hook sends the changed files: for a commit, the staged files; for a push, the files of all pushed commits together. Merge commits add no files of their own. If the hook does not send the changed files, for example because it is outdated or more than 5,000 files changed, the rule is executed and the result shows why. Update the hooks to use the condition for commits and pushes; see Commit and push validation.
If the changed files of a pull request cannot be determined, the rule is executed to be safe, and the pull request shows why.
Examples:
|
Changed files |
Condition |
Result |
|---|---|---|
|
|
Include |
EXECUTED
A changed file matches the include pattern. |
|
|
Include |
SKIPPED
No changed file matches the include pattern. |
|
|
Exclude |
SKIPPED
A changed file matches the exclude pattern. |
|
|
Exclude |
EXECUTED
No changed file matches the exclude pattern. |
In configuration as code, the changed files condition uses the key content; see CaC - Cheat Sheet.
Key takeaway
The pull request condition allows rules to be applied selectively based on source and target branch patterns, and the changed files condition based on the files a pull request, a commit, or a push changes.
Extensibility
The condition model is designed to support additional condition types in the future.