Reputation: 38941
We are using Bitbucket Server and Jira for our git development. They are connected via the Application Links
setting in Bitbucket.
We try to enforce "correct" commit messages (on push) by use the Control Freak Addon. This works fine, but we recently stumbled upon a corner case where I would like to find out whether Bitbucket itself has any option on how it parses commit messages for Jira Issues.
The thing is this: The Control Freak tool has an option to tell it whether to "Look for Jira References" in "First line of commit message" or "Anywhere in commit message". This is fine, I can imagine different use cases on the checker side: One team might prefer checking the whole message, another team might prefer the whole of the commit message.
However, as far as I can tell -- and this is really the QUESTION here -- Bitbucket++Jira will always inspect the whole commit message for Jira issue links.
That is, say you have a commit message like this:
MYJRA-1234 : Fix the checker issue with multiline messages
This fixes the rollout of the setting for
"Look..: Anywhere in commit message" that we rolled out back alongside MYJRA-42
and didn't notice that we checked too little on push.
With this message, Bitbucket++Jira will link the commit with both issues 1234 and 42, displaying both issues in the Issues column in the webinterface, or when you query the issues of the commit via the Bitbucket API.
Now, for us, this is a bit suboptimal, as the second issue does not really apply to this commit at all: So in our case, what would make most sense would be for Bitbucket to only look for Jira keys in the first commit line, thereby enabling developers to mention remotely related issue keys in the commit details without having these issues be linked to the commit.
TL;DR -- So is there any option anywhere in Bitbucket or Jira that would tell the system that I only care about Jira keys in the first line of the commit message?
Note again: Our current setup is with Bitbucket-Server and Jira-Server, but if there is any answer wrt. the Cloud or Datacenter offerings I'd be interested as well.Note that I provided the description for Control Freak here as a background info. I know that Bitbucket Cloud can also check / reject commit messages for issue keys on push. This Question is not about the checker side of things, but about the "link" side of things once the commit is on the Bitbucket side.
Upvotes: 2
Views: 451
Reputation: 38941
Bitbucket Datacenter v9 has more options wrt. the Jira Integration.
They also mention in the Use custom Jira issue keys section :
Bitbucket Data Center assumes that Jira Software issue keys are of the default format (that is, two or more uppercase letters
([A-Z][A-Z]+)
, followed by a hyphen and the issue number, for exampleTEST-123
).
So here the normal rules are mentioned and also a way (integration.jira.key.pattern
) to change the rules.
Since the example regex they give for lowercase letters is rather advanced:
(?<=^|[a-z]-|[\s\p{Punct}&&[^-]])([a-z]{1,10}-\d+)(?![^\W_])
and when testing this also only matches a key that is at the start of the line (according to my regex tester -- I have no datacenter v9 version to test)
(!) => it would appear that Atlassian has:
So, to answer the TL;DR question: Newer Bitbucket DC Versions have options, but to actually change the regex seems still an advanced thing.
Upvotes: 0