I have been using one of the built-in Automation templates to automatically link issues that are mentioned in comments. Default settings are below:
This little rule works pretty well and can be run per project to reduce global rule executions.
However, some of my users started pasting data tables into comments with strings that matched the expression but were not Jira keys. This resulted in a number of emails to my inbox about the rule failing.
I tried to reduce the number of false alerts by making the rule a little more complex. The idea was to verify that a string was an actual Jira issue, in my instance, before trying to link to it.
After the compare block, I added a Lookup issues block with the same expression from above as a smart value in the JQL query. This accurately searches the instance for those items. I can then return the results in a follow-up compare block as a list of matching keys.
If the list of keys is empty, my rule stops, as expected.
If the original string was a partial match to any actual keys, the Lookup issues will only return the matching keys and the rule can continue as planned.
However, if none of the values in the comment matched any Jira issue keys, I still get an error in my inbox. The rule is working as planned, but the Lookup issues failed because there was no match.
Lookup issues
There was an error executing a search during custom value definition: .Custom Smart Value JQL Search: "issue in (HD-3000)" - Issue does not exist or you do not have permission to see it.
Is there a better way to validate if a string matches an issue key that won't treat a false result as an error?
Also, this rule has to be treated as global unlike the original so that the Lookup issues can work correctly. I don't suppose I can get around that.
Hi @Brock Jolet
Adding to Mark's suggestions...
First, do you ever expect more than one issue key in the comment, particularly on different text lines? If so, match() will not work as you expected. Instead you would need to split() the lines, match(), and then recombine the results to form your JQL for the Lookup Issues action.
Next to trap that error you noted, let's assume there is one-and-only-one issue key in the comment. It would be possible to prevent the error by a work-around:
Kind regards,
Bill
Hey Bill!
Once again, you've given me the answer that I needed. Using the API call, I'm able to add an If check looking for {{webResponse.statusCategory}} = SUCCESS.
Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would change that last condition to something like this:
This will make it so if no issues are returned from the lookup issues action, it will not proceed any further.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mark,
I see the logic here, but what I have appears to work for the conditional.
The "error" is happening before then. When the Lookup issues query contains invalid issue keys, it doesn't gracefully stop. I think I'll have to do an if/then before the Lookup issues, but I'm not sure what to base it on.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To confirm my understanding, you're saying that the lookup issues errors when the regex picks up a failed string? In this case, you could try adding the condition I provided previously just after your first lookup issues action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mark,
As an example, a user may paste this into a comment:
Please order a printer, model HD-1000.
In this case, the string HD-1000 matches the regex in the first conditional. It looks like a Jira key. So the Lookup issues block runs this query:
issue in (HD-1000)
Since HD-1000 is not an existing issue key in our instance, the lookup fails. This sends an error to my email.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh that makes sense. Hmm - There may not be a way around this one because the mechanism you're using to validate whether it's legitimate or not will error out when it's not legitimate. If you trust your rule, you could disable error notifications for it. I don't believe you're getting around that error unfortunately.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, that's unfortunate, but I think you're right. Thanks for the help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.