I am no expert on regular expressions. I have the following key pattern:
This is so our Jira project codes match out company coding system. However the following code in a commit is detected as a Jira Issue (CLC0001-1):
prepare release 4701-CLC0001-1.0
Can I improve the key pattern to ignore this kind of match?
Hi again Mark,
I think this will do the trick:
To explain, the first part:
Is a positive lookbehind that means the matched key must be at the start of a line (^) or immediately after a character that isn't in the range a-z, A-Z, 0-9 or a -.
The middle part:
Matches one or more characters in the range a-z, A-Z or 0-9; followed by a dash; followed by one or more numbers.
The last part:
Is a positive lookahead that means the matched key must be at the of a line ($) or immediately before a character that again isn't in the range a-z, A-Z, 0-9 or a -.
If all of your issue keys are three letters followed by four numbers followed by a dash and then another number (i.e. LLL####-#) you can use a slightly stricter regular expression:
These regular expressions are for Java applications (which most Atlassian applications are) as there are some differences between different language's implementations. There great docs on Java regular expressions if you'd like to know more, or if you want to test out other variations, you can use this neat online tool.
Thanks again Tim, I had to put an extra set of brackets around expression for Stash to accept it.
I did have to hack the Stash and Jira databases to remove the false positives; https://confluence.atlassian.com/display/STASHKB/Reindex+JIRA+issue+keysonly seemed helpful for triggering missed keys to be added.
You could use negative lookahead/lookbehinds, non-capturing groups and/or word boundary tokens to achieve this. I'm happy to craft you a suitable regular expression, but to be sure it suits your needs can you give a few examples of what issue keys you do want to match on and what strings you don't want to match on?
Here are some of our commits:
CNC0021-11: Only set the abort if..
2001-CNC0012: Build version...
[maven-release-plugin] prepare release 4701-CLC0001-1.0
Only the first one is a Jira Issue. (The four digits before the Jira code denotes a component, the digits after the code are a version number [when a dot is included])
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot