Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,098
Community Members
 
Community Events
168
Community Groups

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!

0 comments

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira Service Management

An unofficial way to monitor a JSM mail handler for errors

...eturns true if any content is returned for the webResponse.body.data.first s...

668 views 3 20
Read article

Atlassian Community Events