Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Link an Alert to a JSM issue if the key is in the email

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

Hi there,

I have emails coming in to Opsgenie to create alerts and they contain the JSM issue key.

Is there a clever way that I can pull that email out and then link the issue back to JSM?

I know it can be done via the JSM integration, just hoping I can use a value in the email and link it that way also?

Thanks

1 answer

0 votes
John M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 28, 2023

Hi @Ste404 ,

You can use the dynamic field where the JSM issue key is stored at the end of a hard-coded URL. If the alert was coming directly from JSM, it would be stored in the 'key' dynamic field. So you use this format to create a link:

https://JIRA-URL/browse/{{key}}

If it's coming from an email, you would need to have the JSM key be the only value in that field (and then plug that value in where 'key' is in the above) otherwise you would need to parse the JSM key out using string processing and regex:

https://support.atlassian.com/opsgenie/docs/string-processing-methods-in-opsgenie-integrations/

https://support.atlassian.com/opsgenie/docs/regular-expressions-for-improved-alert-filtering/

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

The email is actually being sent from JSM from an automation.  It is set up this way due to a true or false being set in Assets to trigger the email to Opsgenie.

Basically I can put the {{issue.key}} anywhere in the outbound email.

Where can I populate the dynamic field assuming the key is coming in as a value from JSM?

John M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 28, 2023

@Ste404 You can put the {{issue.key}} anywhere in the email, then you would just need to parse it out. For example, if you added the issue key to the email subject, then in the email integration in Opsgenie you would use the {{subject}} dynamic field along with string processing to create the link.

You would need to have some way to parse it out based on some recurring unchanging pattern of where the key occurs in the subject and what text it is surrounded by.

That is what the string processing and regex can help with. In the example below we are assuming that the issue key in the email subject comes after the string 'Key:' and that there is a space after it.

https://JIRA-URL/browse/{{ subject.extract(/Key: (\S+)/) }}

2023-08-28_16-39-04.png

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

Thanks for the info, I will have a muck around with this and see what I can come up with.

 

Stay tuned :)

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

ok that works easy enough and there is a URL back to the issue in JSM.

BUT, is there a way to force it to populate that in the 'Jira Service Management requests' section.

I know I can manually click Link request, but is there a way that it could be inserted as part of the incoming email so when you go into the issue, comment, acknowledge etc, there is a link to JSM formed?

John M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 28, 2023

For the 'Jira Service Management requests' section to be automatically populated, the alert has to be created by JSM.

For alerts not created by JSM, the only way to add a link to a JSM ticket in that section is by manually selecting it. 

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

yep all good, I assumed as much.  There is a link in place now and literally seconds worth of work using that number to link the request.

 

One last thing, is the jira url something that can be extracted.

I know the value is intertwined into what is coming in but not sure where the best place to parse it and then add it to the //URL/browse... side of things.

It is there in the 'from_address, and I was trying to put that in here

 

https://from_address.extract(/@.........../browse/{{ subject.extract(/Key: (\S+)/) }}

the ......... represents where this just goes sideways :D

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2023

Figured it out

 

https://{{from_address.extract(/@(\S+)/)[1]}}/browse/{{ subject.extract(/Key: (\S+)/) }}

Like John M likes this
John M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2023

Glad you got it working!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events