Issues using curly braces in JQL

Greg Bailey April 13, 2021

Hello,

Im attempting to add an automation rule that will have a branch condition JQL to get issues in epics linked to the 'trigger issue'.

The JQL leverages ScriptRunner JQL functions and it includes the smart value of the trigger issue.
The problem is that the rule is failing on the JQL saying the curly brace used for the smart value is a reserved character and to put it in a string or use the escaped unicode value of '\u007b'.

An example of a functioning version of this jql is :

issueFunction in issuesInEpics(" issueFunction in linkedIssuesOf('key=CCFT-2', 'is implemented by') ") AND status != closed

Which in a JQL Branch condition would cleanly look like:

issueFunction in issuesInEpics(" issueFunction in linkedIssuesOf('key={{issue.key}}', 'is implemented by') ") AND status != closed

Below is my current 'version' of the JQL but it is continuing to fail.  I've tried numerous 'combination's of escapes to get this pass but have had no luck.

 issueFunction in linkedIssuesOf('key=\"{"\"{"issue.key\"}"\"}"', 'is implemented by') ") AND status != closed

Another failure failure showing how I had attempted the JQL using the unicode values.

CCFT-2: "(issueFunction in issuesInEpics(" issueFunction in linkedIssuesOf('key=\u007b\u007bissue.key\u007d\u007d', 'is implemented by') ") AND status != closed) AND (key != CCFT-2)" - Error in scripted function: issuesInEpics, see below, Error in scripted function: linkedIssuesOf, see below, Error in the JQL Query: The character '{' is a reserved JQL character. You must enclose it in a string or use the escape '\u007b' instead. (line 1, character 5)

How can I correctly format the JQL with escapes to get this JQL to work when triggered in the rule?

Version info:

Jira Server(not Cloud): 8.53

Automation for Jira: 7.2.8

ScriptRunner : 6.2.2

 

Thanks in advance for any help.

Regards,

Greg

2 answers

1 accepted

0 votes
Answer accepted
Greg Bailey April 15, 2021

Thanks for the response @Curt Holley

You are correct for a single link i.e. a story linked in an epic your solution would work.
However, in my case Im looking for issues in epic with that epic linked to another epic.

the problem was with the jql string I was creating was having issues getting the correct escapes in place to manage the quotes and brackets.  So when I ran the query it failed.

I was able to solve this by using the string quoting of '/'.

I ended up with this and it is now working just fine:

// trigger issue and jql strings
def jqlPrefix=/issueFunction in issuesInEpics("issueFunction in linkedIssuesOf('key=/
def jqlSuffix=issueKey + /', 'is implemented by') ") AND status != closed/

// The JQL query you want to search with
final jqlSearch =jqlPrefix + jqlSuffix


I only got back to this task yesterday and came up with this solution and neglected to post here.   

I'll mark this as done/answered.

Thanks again,

Greg

Curt Holley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2021

Right. I missed the epic linked to another epic part.

Complicated situation, well handled 👍

0 votes
Curt Holley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 13, 2021

HI

I'm only familiar with the Cloud version of Automation, but ignoring my trigger/insert whatever trigger is relevant....wouldn't something like this work? plus no scriptrunner functions required.

idea.png 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events