Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation: Evaluating smart variable inside smart variable

Paulo Sebastião July 16, 2024

Hi team,

I've been a reader on this fantastic forum on a lot of my automations, but now I need help which I couldn't find by googling away.

I have a case where I'm storing apiTokens as project keys (entity properties) for every repo we are responsible for. We don't have Bitbucket premium, so no project keys I'm afraid, so that's why we need keys for every repo.

On a workflow, I want to get the apiKey for the repository associated with the issue (yet again, an entity property on issue level).

I'm on the last step of my workflow, and I want to get the Repo Api Token for a certain {{repository}} based on the {{webResponse.body}} of my call to get Project Entities. Are you with me still?

So basically I'm creating a new variable where the path to access it is

 {{webResponse.body.value.{{repository}}}}

Apparently JIRA Automation is not happy with this and mostly evaluates the whole thing to

}} 

I could, of course, store the repo api key as an issue entity property, but I wanted to keep it central.

Help?

2 answers

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.
July 16, 2024

Hi @Paulo Sebastião -- Welcome to that Atlassian Community!

Although it would be interesting, and quite risky, if automation rules supported dynamic smart value expressions, they do not.

What you could do instead is use your variable to build a regular expression and then use the match() function, passing that expression as the parameter, to get the data needed.

When using this technique, some things to note:

  • Your regular expression variable should not have surrounding quotation marks; they are implied
  • If your search expression contains reserved tokens for regular expressions, first use text replacement functions to add escape characters.  If you need more guidance on that technique, please let me know.

Kind regards,
Bill

0 votes
Mikael Sandberg
Community Champion
July 16, 2024

Hi @Paulo Sebastião,

Welcome to Atlassian Community!

Based on the format my guess is that you get multiple repositories back in the web response correct? In that case you would have to use the Advanced branching so that you can iterate over the returned result.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events