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

Link Automation from Description

Hank November 12, 2021

I developed an automation that parses a Description and saves the IssueKey from any number of URL/Links in the Description. The list of ID's is then used to create Issue Links.

It works, but; two questions

  1. Is there a better RegEx expression?

    Step 3: {{issue.fields.description.match("([\/][A-Z0-9]*[-][0-9]*[^]|^#|^\s])")}}

  2. Is there a more efficient automation flow?

screenshot-2021.11.12-08_23_44 (1).png

 

  Step 5: {{linkIssueKey.replace("/", "")}}

 

1 answer

0 votes
Bill Sheboy
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.
November 12, 2021

Hi @Hank 

If you provide an example of your summary, the community may be able to offer suggestions about the regular expression.  For example,

  • could there ever be more than one linked issue in the summary?
  • are any linked issues in the summary *always* in the same project as the trigger issue?

For your question about "more efficient automation flow", what do you mean?  For example to do this in fewer steps (rule components) you could concatenate all the string manipulations into one expression.  Other than branches, lookups, web requests and re-fetch, performance may not be an issue for many rules, such as this one.

Kind regards,
Bill

Hank November 12, 2021

Hi Bill, I think an ideal solution would allow for any number of issue URL's in the description, and in any location.

I realized that our Description is a Wiki Markup type (default), this means that the  ,match() function is parsing the raw text behind what the user sees in the Screen.  Here's the raw Wiki text from one example Description: 


"As a WV Patient I need to easily understand the Product Information on key pages, such as product pages, shipping information, etc. so that I can make a better decision, quickly on where to invest more of my time. Note: This story is to fix some of the font colors/size etc for better user experience. UP9-9999\n\n

References:

[https://our-domain.atlassian.net/browse/UP-7930#icft=UP-7930|https://our-domain.atlassian.net/browse/UP-7930#icft=UP-7930] \n\n

[https://our-domain.atlassian.net/browse/UP-6744#icft=UP-6744|https://our-domain.atlassian.net/browse/UP-6744#icft=UP-6744]\n\n

and\n\n\
[https://our-domain.atlassian.net/browse/UP-6396|https://our-domain.atlassian.net/browse/UP-6396] \n\n

end more\n\n

[https://our-domain.net/browse/UP-5746|https://our-domain.atlassian.net/browse/UP-5746]\n\n

test 2",


In this case, the result from the .match() should be:

(UP-7930, UP-6744, UP-6396, UP-5746)

This list can then be input to Create Links

/hp

Bill Sheboy
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.
November 12, 2021

Hi, Hank.

If you have RegEx that works, I would stick with that and consider combining your text and list functions to put the key list as comma-separated values (CSV) in one variable.

Now comes the tricky part...I have learned it is not possible to successfully use advanced branching to repeatedly update one issue, even when adding a re-fetch action.  One or more of the asynchronous loops will walk over the updates.

That leaves one option when adding more than one link in one rule: dynamically build a JSON string to perform the update.  https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/#Advancedfieldediting-JSON--Linkingissues

Using list iteration you would build/combine an "add" string for each link, combine into one variable, and then use that in the JSON update.

I recommend building this and just writing to the audit log until you think it is correct, and then try it in the JSON update.  That will save some debugging of errors.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events