Extract Content out of Description and Summary with Regex and Automation

Commonly we find ourselves wanting to get some information out of a ticket summary to use that information for certain fields.

This is commonly a difficult task to do when working on tickets specially those that come via Email.

Today i’m here to show you how you can create an Automation that helps you out and gets that information for you and then automatically dumps it into a specific field.

Before we begin!

For this we will be assisted by REGEX

REGEX is pattern based so we will need a couple pre-requisites before we begin:

I will Take the following example for this.

The text “Email: mail@testing.com“

image-20220830-150205.png

 

In the above text my likely outcome would be to extract the E-mail so I can use it to fill a the Reporter field, or create a new user account or a multitude of options on which this can be helpful to have.

Let me break it down for you.

In the above example “Email:“ would be my recognizable pattern and “email“ will be the text to extract.

As long as we have these elements the rest of the Description or Summary can be whatever, since we know what to look for.

The other two recommendations to follow are the following:

  • If used in SUMMARY the text to extract would need to be at the end of the field.

  • If used in DESCRIPTION the text to extract needs to be in a separate line by itself and always contain a line break.

Recommendation would be to use Template as shown below:

Summary Example

image-20220830-150928.png

Description Example

image-20220830-150717.png

 

NOTE: These recommendations are made so that we introduce the least points of error into this process as possible. 

 

Now that we have set the basis of how this will work we can begin!

Creating an Automation

Go to → Project Settings → Automation → Create Rule

Structure will be the following:

Trigger: Issue Created is the most common one for this example however if you need to do edits because of any other trigger you can do so as well. 

Conditions: Can be any that you feel necessary

Actions: Can be any that you feel necessary. 

  • Only Action required will be the one on which we set the Extracted content. 

Example

image2022-8-30_10-34-25.png

The REGEX to use in this example is : 

{{issue.description.match(".*Email: (\S+).*")}}

{{issue.summary.match(".*Email: (\S+).*")}}

 

Breaking this down:

The part in Bold Section will be our REGEX which translates to: 

 

. matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Email:  matches the characters Email:   literally (case sensitive)
1st Capturing Group (\S+)
\S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
. matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)

 

The rest of the the line is the Smart Value that Allows us to use REGEX as part of our Automation. 

For more information about Smart Values you can review this document:

Smart values in Jira automation

And that's it! if you've made it this far it means that you have finished your Automation and you are extracting information!

 

A couple of notes before we leave!

  • Be ware of spaces! if you introduce spaces into the REGEX and they are not present in the template this process can fail
  • If you are modifying the REGEX I would suggest assisting yourself with tools such as https://regex101.com/ so you can verify your changes against your text!

You've got this!

2 comments

Gomez_ Daniel March 13, 2023

This works great! We were able to extract specific info from the description and send an automated email out. Here's an example of how we used it in automation under the action "send email" in the "content" section:

 

Alert : {{issue.description.match(".*Alert : (\S+).*")}}
Start Time : {{issue.description.match(".*Start Time : (\S+).*")}}
End Time : {{issue.description.match(".*End Time : (\S+).*")}}
Current Value : {{issue.description.match(".*Current Value : (\S+).*")}}
Typical Value : {{issue.description.match(".*Typical Value : (\S+).*")}

Eleonora Light April 26, 2023

I tried the REGEX expression as described in the article. The rule is executed without errors. But instead of the found email address, "Anonymous" is displayed in the Reporter field.
I tried with other field (Labels) and it works fine there. It substitutes the found value into the field.

I use Jira Cloud.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events