Hi,
I want to restrict commits based on a particular commit message template in this repository.
The following is an example of a GIT commit (which should be used as a template) :
git commit -m "JIRA-1234: New files added for XYZ feature"
Please help me to get this template enforced for all commits.
If any commit is not following it, then it should be rejected.
Thanks
Tarun
As it was mentioned, your question has 2 parts: using a commit message template and enforcing/validating that commit message at commit or merge time.
1. Commit message templates (Git native)
Git itself doesn’t natively enforce commit message patterns on the server, but you can use local Git commit templates to pre-fill commit messages for developers.
2. Enforcing commit message compliance (server-side verification)
To block pull requests that contain commits that do not match your required template, you need a verification mechanism and advanced pull request rules for Bitbucket Cloud.
For Bitbucket Cloud, Better Commit Policy Connector for Bitbucket Cloud is a dedicated solution:
It integrates Bitbucket Cloud with Jira Cloud to enforce rules like:
Commit messages must start with a valid Jira work item key (e.g. PROJ-1234:
)
Commit messages must match your regex pattern for structure and length
Commits must link to Jira issues that meet specific conditions (e.g. status is “In Progress”)
Violations are blocked during pull requests via merge checks or flagged in PRs for correction. With Bitbucket Premium, merges can be fully prevented until all commits comply.
Policies are defined in a YAML file in your repo (“policy-as-code”), making them easy to manage and audit across projects.
🔗 If you need strict enforcement in Bitbucket Cloud, Better Commit Policy is the practical and scalable solution.
You can learn more about Better Commit Policy for Bitbucket Cloud here and set up a free trial to test commit message enforcement in your pull request workflow.
Hope this helps clarify both the local template and enforcement options for your team! Let me know if you want example policy snippets to get started or drop me a line at levente.szabo@midori-global.com for a personalized demo.
(I'm part of the Midori team, developing the Better Commit Policy apps.)
Hi @Tarun
There are a few options:
1) Git client side hooks - less convenient to setup, but it is very flexible so you can do enforce a template. It can also be bypassed by the user, which can be a downside depending on your setup.
2) Bitbucket Cloud Jira integration - it can restrict commits that do not have a JIRA key at commit push time. However, you can't enforce a template. See the docs for Require linked issue keys in commits.
Third party apps:
3) Flowie - our Bitbucket addon that supports enforcing a commit template using merge checks via commit policy plugin. You can also enforce JIRA tickets in the PR title, branch, description.
4) Forge - write your own custom app to validate it.
5) There are also other apps in the marketplace that can validate commits too, based on merge checks.
Both, third party apps and Forge can only validate the PR using merge checks, they won't enforce commits during push or commit creation, but they will prevent the PR from being merged. Only 1) and 2) supports enforcing commits during create/push.
You can use a combination of third party apps together with 1) or 2) depending on your needs.
There is also this feature request for Git server side hooks that you might want to check it out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.