Assign fixVersion through automation based on regex
Asked by Graunephar:

Hi   

We have a project where versions are named based on a name scheme that makes them predictable. Like "PROJECT NAME 0.0.1"  

I would like to create a rule that edits an issue and assigns a specific version based on a regular expression.   

Is it possbile to use a regular expression in the fixVersion field to choose a specific version based on its name?  

Please see attached screenshot, where I tried to add some "pseudocode" to the fixVersions field to give an idea of how I envision the regular expression to be used.   

![Screenshot 2022-05-04 at 11.16.33.png](https://community.atlassian.com/t5/image/serverpage/image-id/195771i0EB385E997C4F15C/image-size/large?v=v2&px=999 "Screenshot 2022-05-04 at 11.16.33.png")

Thank you in advance for your help!


Answers:
author: Daniel Graungaard
body: d


author: Daniel Graungaard
body: In ended up using a big workaround. In case another person finds this thread I will describe the gist of the workaround here:   

Since I never release something which has no issues. I decided to use the lookup action in the Jira automation. That way I can lookup and find issues with the version. And since JQL fixVersion supports wildcards I can do what I want.   

The lookup I make looks like this: \`fixVersion \~ "MY VERSION PREFIX\*"\`   
Then I can access the name of the version from the next action by using: \`{{lookupIssues.get(0).fixVersions.get(0).name}}\`  

And that will contain the name of the release. And I can use that as a name to release that specific release.


author: Daniel Graungaard
body: I ended up solving this with a work around. It's not a perfect solution but it works. Im describing it here in case anybody stumbles upon the thread in search of a solution to a similar problem.   

I realised that I never want to release a version that does not have any tickets. And therefore I could use JQL lookup to find all issues with a specific version name. Since JQL lookup for fixVersion can contain wildcards that will make it possible for me to find the release name.   

So in my automation i made this lookup \`fixVersion \~ "MY VERSION PREFIX\*"\`  

And from the next step in the automation I can therefore get the name like this:   
\`{{lookupIssues.get(0).fixVersions.get(0).name}}\`. And I can use that name to trigger the release  

<br />

<br />


author: Bill Sheboy
body: Hi [@Graunephar](/t5/user/viewprofilepage/user-id/4524641)

Thanks! I thought that the {{project}} smart value was only available with the Project Created trigger.

For your question, I believe you will need to use [smart value, list filtering](https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588) to match on the **name** and then grab the **id**value:

{{#project.versions}}{{#if(exists(name.match("(*yourRegularExpression*)")))}}{{id}}{{/}}{{/}}

If it is possible for multiple matches, you may want to put this into a created variable first and then perform some conditional tests.

Kind regards,  
Bill

comments: author: Graunephar
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)   

Thank you for your help!  

Just for clarification (in case anybody stumbles upon this in the future) my example was just something I made up in order to illustrate the problem.   

<br />

<br />

I tried your solution, However it seems that I cannot add your expression to the field. It keeps deleting the content, and there are no way of saving. Seems like the field will only accept concrete names of versions.   

Do you have any idea if there is something else I can do to use the regular expression?


author: Bill Sheboy
body: To use a smart value expression like that in an edit, please try:

* typing (or pasting) in the expression
* it will then appear below the field
* select the value which appears...
* and then it will save for usage


author: Daniel Graungaard
body: Hi [@Bill Sheboy](https://community.atlassian.com/t5/user/viewprofilepage/user-id/1685313)

<br />

Sorry for the late reply.   

<br />

I tried you solution a couple of times now, and when I copy it into the field in Jira the dropdown just say "No options" and there is nothing I can choose. (see screenshot below)

![Screenshot 2022-09-03 at 23.32.15.png](https://community.atlassian.com/t5/image/serverpage/image-id/214209i0B7180E9BF5CB7F3/image-size/large?v=v2&px=999 "Screenshot 2022-09-03 at 23.32.15.png")

I tried putting the regex in as many formats as I could think of. But I just cannot seem to find the format that the dropdown will accept.   

Can you point me in the right direction?


Tags: fix-version

regex

version