Configuration overview - Yet Another Commit Checker

Quick start

  • Download the plugin from Atlassian Marketplace.

  • Install YACC plugin into Bitbucket Server.

  • To set Jira Issue Requirements through YACC, you must also configure a Jira Application Link in Bitbucket Server.

  • Configure YACC globally, per project, or repository.

Modes of operation

YACC can be configured globally, by project, or by repository. There are two modes of operation which can be enabled independently:

  • Hook – YACC checks all commits when they are pushed or added to the repository.

  • Merge checks – Checks are only performed for pull requests. For an unsuccessful check, the pull request is blocked from being merged.

Settings inheritance

You can define YACC settings on three levels:

  • Global: These settings are applied for all projects and repositories by default (if not overridden).

  • Project: These settings work on the project level for all repositories where the YACC hook is configured to Inherited (default).

  • Repository: When the YACC hook is explicitly set to Enabled for a repository, the settings only affect that specific repository level.

Hook settings defined on lower levels override higher-level ones; otherwise, settings are inherited.

Global settings

To configure global settings, click Administration at the top of the page, then click YACC Configuration under the ADD-ONS heading from the Bitbucket Administration page side menu.

See Configuration for settings information.

Pre-receive hook settings

Enable per-project settings

  1. Go to your project and from the side menu click Project settings > Hooks. Yet Another Commit Checker is under the Pre Receive heading.

  2. From the Actions column, click the ellipsis (…) and select Enable from the the Status dropdown.

    See Configuration for settings information.

Enable per-repository settings

  1. Go to your repository and from the side menu click > Repository settings > Hooks. Yet Another Commit Checker is under the Pre Receive heading.

  2. From the Actions column, click the ellipsis (…) and select Enable from the the Status dropdown.

    See Configuration for settings information. 

  3. The hook can also be configured via the Bitbucket REST API.

See Using repository hooks for additional information.

Merge check settings

Enable per-project settings

  1. Open your project and from the side menu select Project settings > Merge checks. Yet Another Commit Checker is under the Merge checks heading.

  2. From the Actions column, click the ellipsis () and select Enable from the the Status dropdown.
    See Configuration for settings information. 

Enable per-repository merge check settings

  1. Open your repository and from the side menu select Repository settings > Merge checks. Yet Another Commit Checker is under the Merge checks heading.

  2. Click the ellipsis () and select Enable from the the Status dropdown.. 
    See Configuration for settings information.

  3. The merge check can also be configured via the Bitbucket REST API.

See Checks for merging pull requests for additional information.

Configuration settings

YACC settings are grouped into tabs, where you can configure the different aspects of the hook.

Where are the configuration settings?

  • Global - Go to Administration > YACC Configuration. Choose from Global Setting - Push Hook, Global Setting - Merge Check, and Advanced Options. Use the Push hook or Merge Check toggle to enable or disable.

  • Project: settings work on the project level for all repositories where the YACC hook is configured to Inherited (default)
    Go to Project Settings > Hooks
    Go to Project Settings > Merge Checks

  • Repository - settings applied at the repository level override global settings. Select the repository you want to change, then from the left panel click

    • Repository settings > Hooks

    • Repository settings > Merge Checks

From any location, click Learn More to open the Yet Another Commit Checker documentation.

All YACC Configuration pages contain different options, depending on where you are configuring the settings (global setting push hookglobal setting merge checkProject Hooksproject merge checks repository hookor repository merge check).

Configuration

General Configuration

Feature

Feature Locations

Description

Feature

Feature Locations

Description

Overriding global configuration

  • global setting push hook

  • global setting merge check

Bitbucket administrator defines who can override hook settings defined on a global level:

  • Global configuration only: Use global configuration for all enabled Project and Repository level hooks and ignore existing settings.

  • Selected group admins: Only selected user groups can change Project and Repository hook settings. All previously configured hooks remain unchanged.

  • All project/repo admins (default): Global settings can be overridden by users with the necessary permissions.

Scan All Commits in Pull Request

  • global setting push hook

  • Project hooks

  • repository hooks

When enabled, the pre-receive hook scans all commits in a Pull Request on a merge attempt, even if they have been scanned before.

Enable dry run mode

  • global setting push hook

  • Project hooks

  • repository hooks

When enabled, the pre-receive hook displays an error but does not reject the push action.

Skip checks on cross-repository pull requests

  • global setting push hook

  • Project hooks

  • repository hooks

When enabled, YACC skips the checks for cross repository request merges. Normally a check is performed on one repository, and then on the other. With this feature enabled, the second check is removed.

Commits

Commit Requirements

Feature

Feature Locations

Description

Feature

Feature Locations

Description

Require Committer Matches Valid User

  • global setting push hook

  • global setting merge check

  • Project hooks

  • repository hooks

  • repository merge check

When enabled, YACC checks that the committer email matches any valid Bitbucket Server user.

Require Matching Committer Email

  • global setting push hook

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, the committer email must match the email of a valid Bitbucket Server user.

Require Matching Committer Name

  • global setting push hook

  • Project hooks

  • repository hooks

When enabled, the committer name must match the name of the Bitbucket Server user.

Committer Email Regex

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When a regex is present, the committer email must match the regex.

Commit Message Regex

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When a regex is present, the commit message must match the regex. Leading and trailing whitespace are ignored.
Example
[A-Z0-9\-]+: .*

requires the commit message to be in the form of:
PROJ-123: added new feature xyz

  • Multi-line Commit Message Regex - Multi-line commit messages can be matched by including newlines into the regex (like (.|\n)*), or by enabling Pattern.DOTALL by starting your regex with (?s).

See Regex is not working for debugging details.

Jira Issues

The Jira Issues tab allows you to set how Bitbucket responds to Jira issues in commit messages.

Jira Issue Requirements

Feature

Feature Location

Description

Feature

Feature Location

Description

Jira App Link

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

Jira application links are used to:

  • Check Jira issues, the building blocks of a Jira project and can be anything from bugs to stories

  • Validate issue keys, used as identifiers for specific work items in a Jira project

When you have multiple application links to your Jira instances, the YACC Jira App Link feature allows you to determine which application links it uses to validate issue keys.

The App Link feature has three options:

  • All - All available Jira application links are used to validate issue keys. Once an issue key is found, validation stops and returns issue data from the first matching Jira instance

  • Primary - The Jira application link configured as Primary at the time of commit is used to validate issue keys

  • Select Links - Only the selected Jira application links are used to validate issue keys

Require Valid Jira Issue(s)

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, commit messages must contain valid Jira issue IDs. Jira issue IDs are defined as any item that matches the regex [A-Z][A-Z_0-9]+-[0-9]+.

 

This can result in false positives if commit messages contain strings that look like Jira issues. For example, UTF-8. Enable Ignore Unknown Jira Project Keys to tell YACC to ignore items that do not contain a valid Jira Project key.

Require Matching Jira Issue In Branch Name

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, issue keys in the commit message are checked against the branch name. The commit is rejected if the branch name does not contain an issue key. The default branch (typically master) is automatically excluded.
Example
Sample commit message PROJ-123 Clean up leftover interfaces from PROJ-3

  • Allowed branch names: bugfix/PROJ-123, PROJ-123-cleanup, PROJ-3-update

  • Blocked branch names: fixes, feature/PROJ-12

Ignore Unknown Jira Project Keys

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, any issue-like items that do not contain a valid Jira project key (for example, UTF-8) in the commit messages are ignored.

Issue JQL Matcher

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When a JQL query is present, detected Jira issues must match this query.
Example
assignee is not empty and status="in progress" and project=PROJ requires Jira issues be assigned, in progress, and from project PROJ.

Additional topics

See Jira Advanced Searching for documentation regarding writing and testing JQL queries.

See Jira authentication failed message article in the Troubleshooting section.

Branches

The Branches tab is used to set branch naming requirements.

Branch Requirements

Feature

Feature Locations

Description

Feature

Feature Locations

Description

Branch Name Regex

  • global setting push hook

  • Project hooks

  • repository hooks

When present, only branches with names that match this regex can be created. This also affects branches created within the Bitbucket Server UI. This only affects new branches and branches created within the Bitbucket UI; existing branches that do not match this regex are allowed.
Example
master|(?:(?:bugfix|hotfix|feature)/[A-Z]+-\d+-.+) branch names must follow the Bitbucket Server Branching Model naming convention.

Exclusions

Exclude

Feature

Feature Locations

Description

Feature

Feature Locations

Description

Exclude Personal Repositories

  • global setting push hook

  • global setting merge check

When enabled, commits and PRs to personal repositories are not included in checks by YACC. Excluding personal repos allows your organization to define additional rules on the global level without encountering exceptions for repos that are not required to adhere to those rules.

Exclude Commits From Bitbucket UI

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, YACC skips validation of changes made through the Bitbucket UI. This includes edits from the built-in web editor and the Apply suggestion feature. The latter does not display a rejection message and does not allow repeat attempts even after correcting the commit message (Bitbucket bug report), so it may be useful not to validate such changes.

Exclude Merge Commits

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, merge commits are excluded from commit requirements. This includes merge commits pushed through the command line and merges made via the Pull Request UI.

Exclude Commit by Regex

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When present, commits are excluded from all requirements if part of the commit message matches this regex.
Example
^Revert \"|#skipchecks

Exclude Branch by Regex

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When present, commits on branches that match the specified regex are excluded from all checks. Branch regex exclusion is applied before the Branch Name Regex option; i.e., branch creation is never blocked when a branch matches the Exclude Branch pattern.
Example
experimental/.*

Exclude Service User Commits

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

When enabled, commits from service users (i.e., using SSH Access Keys) are excluded from commit requirements.

Exclude User

Exclude Group

  • global setting push hookglobal setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

Select from the dropdown lists of Bitbucket User Names or Groups. Commits from these users or members of these groups are excluded from commit requirements.

Error Messages

Error Message Customization

Feature

Feature Locations

Description

Feature

Feature Locations

Description

Error Messages

  • Header

  • Committer Email Error

  • Committer Email Regex Error

  • Committer Name Error

  • Commit Regex Error

  • Issue JQL Matcher Error

  • No Jira Issue Error

  • Footer

  • global setting push hook

  • global setting merge check

  • Project hooks

  • Project merge checks

  • repository hooks

  • repository merge check

The Error Messages tab allows you to customize various messages produced by the YACC hook. For each entry, you can add a customized error message that replaces the default error message.

Example message

To add a customized error message to help ensure internal policies were being followed, a heading message could look like this:

Your commit message does not conform to organizational requirements. Contact your Bitbucket repository administrator for details

Add your message to the appropriate field; in this case, the Header field and click Enable.

When triggered, Bitbucket displays the custom error message:

Advanced Options

  • Configuration

    • Jira Authentication User - By default, YACC uses the user account associated with the committer to make a connection to Jira to validate issues, run JQL queries, etc. This can cause authentication issues when the user pushing the code does not have read access to the corresponding Jira project. Examples include commits from continuous integration or commits made through SSH access keys.
      The specified username is used for all Jira queries if this parameter is configured. There must be a valid Bitbucket username associated with a Jira account.
      The Jira Authentication User parameter can only be specified in the global settings. The setting is shared between the pre-receive hook and the merge check.

  • Jira Issues

    • Allow Lower Case Jira Issue Keys - When enabled, the Require Valid Jira Issue(s) configuration uses case insensitive matching to find Jira tickets.

Click Save Advanced Options after any changes.