Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira Automation Rule: How to use a smart value in a regex match pattern

Hey there,


I'm writing a Jira Automation Rule that is making a web request to gitlab. In the next step of the rule, I am trying to perform a regex match on the data using a pattern which needs to contain the value of another string variable I saved earlier. I want to save the matching string to a new variable I can use later.

Save the result of this regex match to a new variable:

{{apiData.match("(id=\d+[\w ,\n/\-.=]*?path_with_namespace={{myJiraSmartValue}})")}}


When I try this though, I get back the below error:

Error rendering smart-values when executing this rule:Failed to get value for apiData.match("(id=\d+[\w ,\n/\-.=]*?path_with_namespace={{myJiraSmartValue: {{apiData.match("(id=\d+[\w ,\n/\-.=]*?path_with_namespace={{myJiraSmartValue}})")}}

It looks like my syntax is incorrect when I do the above, the first pair of closing braces }} causes the evaluation of the whole expression to short circuit.


To get around the above, I tries saving the entire regex to a new smart value variable called myRegexPattern like so:

{{"(id=\d+[\w ,\n/\-.=]*?path_with_namespace=myJiraSmartValue}"}}


Finally, when I try to perform the regex match by passing in the myRegexPattern variable, I get back zero results:



I KNOW that my regex pattern is correct because I've tested this scenario by replacing the variable with a hard-coded value. I can't just do this though because I won't always know what the value of the variable is... which is why I am using the variable in the first place! Does anyone know how I can pass in a variable to the regex string match function??


Thank You

2 answers

1 accepted

0 votes
Answer accepted

Hi @joshua.peeling 

In addition nesting smart value issues, I believe another issue you are encountering is that created variables cannot consistently be used as parameters in function calls for other smart values. For example: {{issue.summary.match(myCreatedVariable)}}  I put in a support ticket for that a while ago and heard back: not intended to work that way...yet.

You do not show how you are determining {{myJiraSmartValue}} and I wonder if:

  • You incrementally search/reduce the string in steps, and
  • Always have the created variable as the first expression if that will help.  For example, {{myCreatedVar.somefunction(...

My other work-around was to parse the response calls into name/value pairs, split the lists, and the match on what I need with RegEx.

Best regards,


Hey @Bill Sheboy

Yes that seems to be my exact issue, I cannot consistently use my created variable as a parameter in a function call for another smart value. The inconsistency is extremely frustrating because I had based my whole logic for my Jira Automation rule around the fact that I would be able to pass in {{myCreatedVariable}} to the .match() function. It doesn't make sense that I can pass in a variable to something like .plus() but not the regex function. And there's no documentation to explain this is the case!

To get off my soapbox though... The way I am storing the {{myJiraSmartValue}} is that my Jira Rule triggers whenever a Pull Request on a Jira ID has been merged. I am grabbing the pullRequest.url value, and doing a .match() on that to strip part of the URL path away and just leave me with the unique section of the URL that would take me to the gitlab project where the Pull Request was merged. Then I am storing that stripped value in the {{myJiraSmartValue}}.

Later, I then make a call to the below API:{{48 hrs ago}}

Then I am storing the json list of projects that I get back in response to another variable (call it gitbabRecentlyUpdatedProjects). Then I am trying to perform gitlabRecentlyUpdatedProjects.match(partial regex pattern + myJiraSmartValue), to get back another strip of information nested in the json response that I need.

Thanks for explaining, Joshua.  How about these alternatives:

Although you cannot consistently use the created variable in a function, they do seem to consistently work as the left-most expression: {{myCreatedVar.aFunction(asdfasds).anotherFunction(asfdasfasdfa)...}}  So if you can organize your rule that way it might work.

The other alternative is one from performance improvement: in-line the expression.  Once you believe you have the pieces working, try to perform that match in one single operation, without using any created variables.  I cannot tell if that is possible from your use case. 

Please note: for this second alternative, save your work as you incrementally build the rule.  If you have an error in complex RegEx, the rule builder can hang during publish.  I often work in a text editor to build up my rule's expression...just in case the rule editor hangs and loses my changes.

@Bill Sheboy Thanks for the additional suggestions! Fortunately I was able to work around this issue entirely from the perspective of the API WebRequest I was sending.

I was able to narrow down the API response data to just the specific gitlab project that I know had changed. Because of this, I was able to update the regex I was using so that it didn't need to make use of a variable.

I definitely still think the use of variables as parameters within functions called by another smart value should be more consistent - I stick by my previous remark that it doesn't make sense I can pass in a variable to something like .plus() but not .match(). There should at least be documentation that makes this clear.

But thanks again for the help!

Like Bill Sheboy likes this

I am glad to hear you got it to work by altering your response data.

Of note, here are a suggestion and a defect related to improving the issues you note for created variables.  Resolving either one of these would have made your use case much easier to implement.

Like joshua.peeling likes this

Found this post, has a bit of discussion about this -

And it ended up with a feature request:


So it looks that nesting smart values is just not possible - so this would need to be likely a few ugly .matches() AND .matches() AND .matches() or something to that extent.

I see... unfortunately I don't think doing a .matches() AND .matches() AND .matches() will work, because without passing in my variable, the regex will potentially have multiple results. The only way to narrow it down from there is to make use of the variable I have, and if I can't pass it in as part of the .matches() function then I don't know how else I will be able to get just the one match I'm looking for.

Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Marketplace Apps & Integrations

Why everyone using Jira must be GDPR-compliant

Did you know that penalties up to 4 % of the yearly company turnover are possible in case of GDPR violations? GDPR regulations are currently mainly relevant for companies in the EU, but countries lik...

103 views 1 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you