🚀 Cloud launch alert: Better Commit Policy for Jira Cloud plus Bitbucket Cloud Connector are now live! → Get started here

Pull request rules in Bitbucket Cloud

Bitbucket Cloud lets teams manage code reviews and merges, but it doesn’t natively enforce every pull request rule that engineering managers, tech leads and compliance officers might want. In regulated industries, you may need rules for a standard pull request description, pull request title or branch condition.

To achieve stronger controls, teams need dedicated solutions like the Better Commit Policy Connector for Bitbucket Cloud app, which connects Bitbucket to Jira and sets rules for commits and pull requests via custom merge checks.

Bitbucket Cloud pull request rules by Better Commit Policy

Overview of built-in Bitbucket Cloud pull request controls

First, let's see what pull request controls are available out of the box in Bitbucket Cloud.

You can set branch restrictions and merge checks to ensure only compliant changes are in a pull request. For example, you can restrict who can merge changes into a branch by adjusting the write access or require a minimum number of reviewers on a pull request before merge.

In the repository’s branch restrictions settings, you can also enforce conditions like "no unresolved tasks" "no requested changes," and (on Premium plans) block merging until all merge checks pass.

The built-in merge checks include:

  • Minimum approvals: Notify or block a merge unless a pull request has X approvals (including special checks for default reviewers).

  • No open tasks: Warn or prevent merging if any pull request task is still open.

  • Build status: Require a certain number of successful CI builds on the latest commit.

  • Reset approvals on change: A Premium-only feature that automatically removes all approvals if new commits are added to the pull request.

  • Prevent merge with unresolved checks: This is key for compliance-aware teams and also Premium-only. It blocks the merge until every selected check is resolved (without Premium non-compliant changes are just flagged but can be merged).

In addition, Bitbucket Cloud lets you define default reviewers (so certain people are auto-added to every pull request) and default pull request descriptions to remind authors of guidelines.

How do you ensure that a Bitbucket commit message links to a Jira work item? How do you block a pull request if the author is not among the code change committers?

Without a dedicated app, Bitbucket Cloud can’t enforce things like a specific commit message format, branch-name patterns, or requiring a Jira work item key in every pull request. For those, you need dedicated solutions implementing custom merge checks.

What are tasks in Bitbucket Cloud?

Tasks in Bitbucket Cloud are not to be mixed with Jira work items or similar.

Tasks in Bitbucket Cloud are much more like a to-do list attached to the pull request. Lightweight, actionable items that can be added automatically to every pull request using "default tasks". Reviewers or authors can add tasks to a pull request or turn comments into tasks.

Tasks typically highlight required changes, improvements, or follow-up actions before a pull request can be merged. Each task appears as a checklist item within the pull request, and all tasks must be resolved (marked as complete) to satisfy certain merge checks.

While Bitbucket Cloud allows you to require that all tasks are resolved before merging, this is ultimately a manual process. Bitbucket Cloud does not verify the actual completion or quality of the tasks themselves.

To enforce requirements written in tasks in an audit-proof way, you need a solution like the Better Commit Policy Connector for Bitbucket Cloud.

Better Commit Policy extends Bitbucket Cloud pull request rules

Engineering managers and compliance officers typically want pull request rules that guarantee code quality and traceability.

Bitbucket Cloud pull request rules that Better Commit Policy Connector implements:

  1. Enforce pull request title rules: Require that every pull request title matches a specific pattern or includes required keywords, such as a Jira work item key or a ticket reference. This ensures traceability and consistency across all code changes.

  2. Enforce pull request description rules:
    Mandate that pull request descriptions follow a defined template or contain certain sections with required contents like Jira references (e.g., summary, testing steps, impact, connected Jira work item key). This helps reviewers quickly understand the context and purpose of the changes.

  3. Set pull request rules for source branch name: Define naming conventions for source branches (e.g., "feature/", "bugfix/"), or including a Jira work item key that is assigned to the pull request author. This prevents merges from branches that don’t comply with your workflow or traceability requirements.

  4. Set pull request rules for destination branch name: Restrict Bitbucket Cloud pull requests so they can only target specific branches (like "main", "develop", or release branches), or enforce naming patterns for destination branches to align with your release process.

  5. Rules for commits in the pull request: Require that every commit in the pull request meets specific standards, such as following the Conventional Commits specification for commit messages, or ensuring that the commit author matches the pull request author.

Matching commit authors with pull request authors is a sensible rule for traceability and accountability, especially in regulated environments. This ensures that changes in a pull request are authored (or at least co-authored) by the person submitting the pull request, preventing unauthorized or anonymous changes from being merged.

Example pull request rule configuration

Here is an example of how you configure your pull request rules with Better Commit Policy Connector for Bitbucket Cloud.

This approach is called "policy as code," meaning your pull request and commit rules are defined in a version-controlled configuration file, making them auditable and scalable for enterprise use cases.

Start with this ".commitpolicy.yml" file and read more examples for pull request rules.

In the below example, you find Bitbucket Cloud pull request rules for title, description, source, and destination branches. In case of violations, the rejection message is shown to developers.

pull-request:
  rejection-message: "Write a 10+ char long pull request title, starting with a valid SDAI work item key! Also, write a 10+ char long pull request description!"
  title:
	pattern: (?s)SDAI-\d+ [A-Z0-9](\S|\S\s*){10,}
	work-item:
	  jql: 'project=SDAI and statusCategory="In Progress" and assignee="$pull-request.author"'
  description:
	pattern: (?:\S|\S\s*){9,}
  source-branch:
	pattern: (?s)feature/SDAI-\d+ [A-Z0-9]{4,}
	work-item:
	  jql: 'project=SDAI and statusCategory="In Progress" and assignee="$pull-request.author"'
  destination-branch:
	pattern: (?s)SDAI-\d+ [A-Z0-9](\S|\S\s*){10,}	

With Better Commit Policy Connector for Bitbucket Cloud, these rules are defined as code and enforced automatically.

If a commit or pull request violates the rule, Better Commit Policy will flag the problematic change and (with Bitbucket Premium) prevent the merge entirely.

Developers then fix the issue (for example, by renaming the branch or correcting the commit message) before the pull request can be merged. As a result, errors are caught early, non-compliant code changes are blocked, providing clear trace for reviewers and auditors.

Getting started with Bitbucket pull request rules

By combining Bitbucket Cloud’s native merge checks (approvals, CI status, tasks) with Better Commit Policy’s checks, teams can cover virtually all pull request rule needs.

Better Commit Policy connects Bitbucket Cloud and Jira Cloud so that policies can rely on Jira data and ensure pull request information is displayed on the Jira side.

Follow these steps to get started:

  1. Install both Better Commit Policy apps: Install Better Commit Policy for Jira Cloud to your Jira Cloud site and then install the Better Commit Policy Connector for Bitbucket Cloud app.
  2. Connect it to your Bitbucket workspace following the instructions in the documentation (one-time setup).
  3. Add the custom merge check. Follow these instructions.
  4. Define the policy file. Create and add the commit policy file we looked at in the previous section to the repository. See instructions.

Combine native and custom merge checks for complete pull request control

Effective pull request rules in Bitbucket Cloud combine Bitbucket’s built-in controls (branch restrictions and merge checks) with purpose-built change control for commits and pull requests.

Better Commit Policy Connector for Bitbucket Cloud is a dedicated solution: it integrates with Bitbucket Cloud and Jira Cloud to enforce custom rules on commit messages, branches, pull request titles, and descriptions. The result is higher code quality, full traceability, and audit-ready workflows.

Better Commit Policy Connector for Bitbucket Cloud (Free)

 

Be the first to hear about the Midori news, Jira, Confluence, Bitbucket guides, and productivity tips that accelerate your team.

Subscribe now