Skip to content

Add prefix and custom match options for custom Jira issue matching

What does this MR do and why?

Describe in detail what your merge request does and why.

Transform reference_pattern method for Integrations::BaseIssueTracker and corresponding subclasses into an instance method to be able to use modifiable regex patterns for issues in subclasses.

Unfortunately, there are dependencies on the static method, I have therefore opted into using a renamed static method to help maintain functional compatibility with code relying on having a superset of subclass reference patterns with BaseIssueTracker (e.g. the Banzai filter) while breaking API compatibility. Tests should discover if I missed anything.

Add option for prefix and custom issue matching pattern for Jira integration. Both of these options are input into a regex, therefore full Ruby Regex engine feature set can be utilized by users.

Add these configurations into the Jira Configuration section in the integrations settings UI. This section was pre-existing in frontend code.

This helps with #384503 (closed) as having better control over regex provides means to control what issues are matched and which ones are not. Also enforcing a prefix helps with preventing accidentally mentioning issues.

Splitting regexes for matching issue keys and prefixes covers a case, where a user wants a prefix but doesn't want to modify the default matching behavior. Including the prefix outside the issue matching group: <?issue> without using something like the following group (?<=) makes the prefix a clickable link together with the issue key. Not being inside the issue match group helps visualize that prefix, and the issue key together made the match, promoting visibility to the correct form.

Screenshots

Default configuration

jira_conf_no_settings

Setting custom prefix

jira_custom_prefix

The issue note matched only the prefix input into the Jira Integration Settings.

matched_issue

How to set up and validate locally

  1. Migrate

  2. Enable Jira integrations on any project: navigate to Settings -> Integrations -> Jira

  3. Modify the values in "Integration configuration"

  4. Save

  5. Create a string corresponding to these new settings in any Mentionable object such as: issue comment, note on an MR, commit message, ...

  6. The string should be matched according to the rules. Default rules are no longer applied if this setting is non-empty.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #384503 (closed)

Fixes: https://gitlab.com/gitlab-com/account-management/eastern-north-america/red-hat/red-hat-kernel-team/-/issues/123

Edited by Jarek Prokop

Merge request reports

Loading