Hello,
I've been struggling with Jira automation when it comes to trimming certain content of the descriptions/comments in our JSM tickets, as most of them are internal and come to us by mail, including business signatures.
I've been testing with smart-values and the methods they offer to search for content or text replacements.
After some trials I've seen that the replaces are made on the description content obtained from the Jira Rest API (https://[atlassian-instance]/rest/api/2/issue/[issue-key]?expand=names)
Here is the text that I'm testing on to do some replaces:
{color:#1F4E79}prueba{color} \n\n{color:#1F4E79}{color} \n|{color:blue}{color} !http://some-url/img.png!{color:blue}{color} <[http://some-url/]>{color:#1F4E79}{color} | *{color:black} *<<User_Name>>*{color}* | \n| *{color:gray} *Job_Name*{color}*{color:black}{color} | \n|{color:black} Company{color} | | \n|{color:black} Tel.: 000000000 Ext. 0000{color} | \n|{color:black}{color} [{color:black}{color}{color:blue}mail@domain.com{color}{color:black}{color}|mailto:mail@domain.com]{color:black}{color} | \n|{color:black}{color} [{color:black}{color}{color:blue}http://some-url{color}{color:black}{color}|http://some-url]{color:black}{color} | \n|{color:blue}{color} !http://some-url/img.png!{color:blue}{color} <[http://some-url/]>{color:blue}{color}!hhttp://some-url/img.png!{color:blue}{color} <[http://some-url/]>{color:blue}{color}!http://some-url/img.png!{color:blue}{color} <[http://some-url/]>{color:blue}{color}!http://some-url/img.png!{color:blue}{color} <[http://some-url/]>{color:blue}{color}!http://some-url/img.png!{color:blue}{color} <[http://some-url/]>{color:#1F4E79}{color} | \n \n\n{color:gray}«Legal-Text»{color}
Here is a sample of the regex that I've made and should be working (I have generalised it because the current one contains data from the company I work for).
\|\{color\:blue\}\{color\} \!http\:\/\/some-url\/img\.png.*?(\{color\:black\} \*.*?\*\{color\}\* \| \\n\| \*\{color\:gray\} \*.*?\*\{color\:black\}\{color\}).*?\u00BB\{color\}
I've tested the regex on some online regex testers and it should be workin properly but it's not the case. The rule's Audit Log shows a succes but on the log message the replacement has not been made.
The rule is configured for now like this:
Any idea of what I'm missing?
Hi @jhonrubia
There are two things I can confirm when using complex regular expressions with Automation for Jira (A4J) rules:
a) The Atlassian documentation notes that the automation regular expression parsing is based upon the Java Pattern class and Matcher, and I have found it does not support all of the features described for Java. You will need to experiment, and probably stick to basic syntax. For example, it is possible one or more of the characters you have tried to escape cannot be escaped in this tool.
b) Divide and conquer to build/test your expression with test rules writing to the audit log, piece by piece. As you build up a working regular expression, you will find where it stops working. And then perhaps you can substitute in the non-regular expression Remove() or Replace() functions, chaining multiple replacements together to get your desired results.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.