Integrating with custom JIRA issue key
症状
JIRA has a UI to help specify a custom issue key format. When integrating with Stash, these custom JIRA issue keys are not recognized by Stash and hence commits are not linked to the JIRA issues.
原因
Stash passes commit messages through a regex pattern to identify and create links. The custom JIRA issue key format will not work with the default pattern that Stash is shipped with:
((?<!([A-Z]{1,10})-?)[A-Z]+-\d+)
ソリューション
Follow the steps below to modify the regex pattern:
1) Shut down Stash.
2) Edit the contents of the <Stash installation directory>/bin/setenv.sh or <Stash installation directory>/bin/setenv.bat (depending upon your OS) and add the modified regex to the variable JVM_SUPPORT_RECOMMENDED_ARGS.
3) Save the file.
4) Remove the contents of the following folder:
バージョン | Folder location |
---|---|
Up to 2.10.x | <STASH_HOME>/caches/idx-snapshots |
2.11 以降 | <STASH_HOME>/data/snapshots |
3.2 以降 | <STASH_HOME>/shared/data/snapshots |
5) Restart Stash.
6) Push to the repository with the JIRA issue key in the commit message to force a reindex of the data.
For example, to match JIRA keys such as C001-1 or ABC123-1, set the variable as follows:
2.8 よりも前
JVM_SUPPORT_RECOMMENDED_ARGS="-Dstash.jira.key.pattern=\"((?<!([A-Z0-9]{1,10})-?)[A-Z0-9]+-\d+)\""
2.8 以降
JVM_SUPPORT_RECOMMENDED_ARGS="-Dintegration.jira.key.pattern=\"((?<!([A-Z0-9]{1,10})-?)[A-Z0-9]+-\d+)\""
If the parameter is set correctly the following line will be logged in the <STASH_HOME>/log/atlassian-stash.log
:
2012-10-23 13:43:16,805 INFO [main] c.a.s.i.jira.idx.JiraKeyIndexer Using custom JIRA key pattern: ((?<!([A-Z0-9]{1,10})-?)[A-Z0-9]+-\d+)