Rule Name :
'Rule Name' is used to uniquely identify each rule. Rule Name can not be duplicated.
In case you try to re-use an existing rule name, you will get a warning as shown below.
Mode Selection (Basic / Regex)
We have provided two modes "Basic Mode" & "Regex Mode" to parse the field logic / pattern mapping.
Mode provides users with the flexibility to input data freely in Basic Mode or utilize regular expressions in Regex Mode. This empowers users to define patterns according to their preferences. The following guide outlines the process of mode selection, the Pattern Mapping dialog box, and validation procedures in both Basic and Regex Modes.
The highlighted yellow area represents the Mode checkbox, with unchecked indicating Basic Mode and checked indicating Regex Mode. Default mode is Basic, checking the box switches to Regex. Multiple mapping rows can be added.
In Basic Mode, users can freely input data within curly braces "{value}" into the Pattern Field. Please visit
Field Parsing Logic
Let's get familiar with the Pattern syntax in Basic Mode.
The pattern must always contain the string "{value}" in Basic Mode.
Pattern may optionally contain a prefix and/or a suffix
The plugin uses regex matching in the backend. Based on prefixes and suffixes tries to pick the relevant string from the Source Field.
The "{value}" string part will be identified and populated to the corresponding custom field
If a suffix is not provided, then only the current line would be matched. By providing a suffix you may match multi-lines.
Casing and space chars in prefix/suffix need an exact match with the Source Field.
It is okay to add multiple mappings for the same Custom Field. You may leverage this to handle Casing/Space chars.
Let's look at an example to see the plugin in Action
Imagine we have added a pattern mapping as shown below:
Now let's add the following Sample Comment to the Jira Issue:
username=Jira-ADMIN |
---|
Based on the above mappings the following would happen:
Custom field 'Employee Name' is populated with value 'Jira-ADMIN'
'Employee Address' field is populated with value '5th Floor, Tower ‘X’,Silver Enclave,Airport Road, Bengaluru'
'Total Score' field is populated with '7'
'Server URL' field gets updated as 'https://mgtechsoft.atlassian.net'
The 'Actual Start Date' field gets updated as '25/Aug/22 10:55 AM'
Lastly the 'Last Comment Field' is populated with the whole of the comment text. ( You may use this trick to maintain a custom field which stores the Last Comment added to issue )
Please note, only if the input field (Comment/Description/Rich Text fields) contains Jira accepted field values it would be populated in the Custom Fields.
Eg : Providing text field to a Numeric Custom Field, would fail to populate the Custom Field. Similarly for date field, URL fields etc..
Please visit "Supported Fields" section of the Documentation for more details.
In Regex Mode, users can utilize regular expressions in the Pattern Field. Please visit
Use the check box highlighted below in the Create/ Edit or Clone dialogue to enable Regex mode for a particular rule item.
Next, provide a regex pattern in the ‘Pattern’ input. PFB is an example.
When in action, the input rich text field would be checked against the regex pattern for a match, if a match is found the same would be updated to the ‘Priority’ field in Jira.
Regex Helper
We recommend to Visit the 'Manage Apps’ → ‘Regex Helper' module in your Jira to test Regex patterns against input texts before using them in Rules.
The Regex Helper tool is designed to assist users in performing regular expression matches on input data. Users can input a valid regular expression and a set of data, and the tool will automatically perform the match.
Valid Regular Expression:
Crafting a valid regular expression requires precision in considering the pattern's structure and matching criteria. Successful matches, shown in blue, exemplify the data to be inserted into the custom field on the issue page, while red highlights indicate mismatches.
In this example, the given regex pattern is returning a value ‘High’ based on the input data. Once the same pattern is used in a Rule as shown below, the rule can set the field ‘Priority’ as ‘High’.
Invalid Regular Expression or Input Data:
When the regular expression is invalid or a regex match is NOT found in in the Input Data, a corresponding error message is shown in Red color. Tweak the regex/ input data to get a success output before using it in a actual rule.
Clearing Input Fields:
To clear the input fields, entered values in both the "REGULAR EXPRESSION" and "INPUT DATA" fields, and then click the "Cancel" link. This action will swiftly reset both fields, providing a convenient way to start fresh.
Sample regex patterns for reference:
Guide on regex patterns! Below, you'll find a collection of sample regular expressions (regex) to help you validate and extract phone numbers from text etc….
Input Data |
---|
priority=High |
Priority Extraction:
Regex: priority\s*=\s*(\S+)
Extracted Value: High
Name Extraction:
Regex: name\s*=\s*([a-zA-Z]+)
Extracted Value: ABC
Profile Extraction (up to 3 lines):
Regex: profile=(.(?:\n(?![a-z]+=).)*)
Extracted Value: ABC,
more details here,
Thank you.
Email Address Extraction:
Regex: assign\s*=\s*([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})
Extracted Value: admin@admin.com
Phone Number Extraction:
Regex: phone\s*=\s*(\+?[0-9\s-]+)
Extracted Value: +1234567890
You can refer Regex Helper Module to know about how to validate your regular expressions.
Pattern Field Validation:
The data will undergo validation if the Pattern Field is either empty or contains invalid data. In such instances, the Pattern field will be visibly displayed in an orange color. This validation process applies to both Basic and Regex modes.
If the 'Pattern' field is empty or not in the expected format when adding a pattern mapping, a popup message appears at the top, highlighting the respective field for user attention and correction.
After carefully selecting all the fields and ensuring that the specified condition in the Pattern field is met, proceed to click on "Add Pattern Mapping" to observe the newly created rule on the 'Configure Comment Handler' page.
Rule Priority
What if we have multiple rules defined which a which might be applicable for a particular Jira Event.
This comes into picture when you have rules defined for 'All Projects' and or 'All Issue Types' which are called 'Global rules' depicted with 'G'
Consider the four rules above. Imagine we are Creating a 'Task' in 'Business Project'.
Here even though all the rules match this Create Issue Event, the rule which is defined at the most fine grained level would take priority over Global Rule and would execute
Here the priority would be in the order : ddd > qqq > 111 > aaaaa
Please note: You won't be able to able to add multiple rules for the same 'Project' and 'Issue Type' combination.
In case you try to add the same, system would prompt you whether you wish to overwrite the existing Rule.
Clicking 'OK' would replace the previous rule with this new rule. Instead you may choose another Project/ Issue Type combination and proceed as well.