通过注释格式强制 Bitbucket Commit 关联到 JIRA Ticket

Force Bitbucket Commit to be associated to JIRA Ticket by Comment Formatting

确切的需要是强制将所有提交到 Bitbucket 的内容链接到 JIRA 票证。

我之前在 Subversion 上通过创建一个在提交文本中查找 JIRA 票证的提交挂钩来做到这一点,但我不希望这个解决方案必然受限于之前的经验。

Bitbucket 是否有设置强制关联所有针对 Jira 票证的提交?如果没有 - 它是否有强制提交评论质量的机制(某种钩子或正则表达式)?如果没有 - GIT 是否有我们可以用于此目的的东西?

设想的解决方案是(但不限于)提交挂钩,如果评论文本不包含前导 JIRA 票证,后跟冒号,然后是一些提交文本,则提交挂钩失败,例如:

git commit -m "foo"

失败并且

git commit -m "PRJ-9327: foo"

提交...

更新(2017 年 4 月 14 日)

看起来此功能已集成到 JIRA 主线中,应该会很快发布。有关详细信息,请参阅

原回答

有许多 Bitbucket 插件可以做到这一点。例如Commit Policy Plugin for Bitbucket(免费)

披露:我与我提到的插件背后的团队没有任何联系。

BitBucket issue 5658今天(2​​017 年 4 月 13 日)刚刚实施

Option to reject commits without an issue key in their message

This feature is now available to all users via the repository settings "links" page

The pre-receive hook that rejects pushes when any commit does not have a valid issue key in its message.
The current implementation relies on the per-repository "Links" setting to determine what a valid issue key looks like. This gives us the ability to validate against Jira, Bitbucket Issues, Connect add-ons, and any configured custom Links.

因此您不再需要第三方插件。