How can I replace part of a file path using Jira Automation?

Steven Johnson
Contributor
November 21, 2024

I have a lot of issues that contain a file path in the notes field, that I need to update a small part of the path. Since bulk update is not flexible enough to accomplish this, I was going to use Jira Automation and run a scheduled rule, searching for the issues that contain the file path and edit the notes field, to update the link (while also retaining everything else that is in the notes). I have worked out the RegEx expression I will need, I know how to use the "replaceAll" function within a smart-value, but I cannot figure out how to combine them, because I get an error when I try and run it to test the action.

Here is an example of a filepath that I would like to update:
\\abcnetwork\Group_Folder\Team Folder\folder 1\folder 2\example.txt

I just want to add "(addme)" to the "Team Folder" so that it reads "Team Folder (addme)" within the filepath.

Here is what I currently have in the edit action of the rule for the notes field: {{notes.replaceAll("(\\\\abcnetwork\\Group_Folder\\Team Folder)((?:\\.*b)+)","$1 (addme)$2)}}

I get the following error within the rule's audit log: Error rendering smart-values when executing this rule: Failed to get value for"

How can I format the smart-value in order to update my notes section?

Thanks!

1 answer

1 accepted

3 votes
Answer accepted
Jim Knepley - ReleaseTEAM
Atlassian Partner
November 21, 2024

Hi @Steven Johnson 

The replaceAll function replaces matching substrings with the replacement expression. I would try something as simple as this:

.replaceAll("(Team Folder)", "$1 (addme)")

 

Steven Johnson
Contributor
November 21, 2024

I thought that was one of the 1000 things i've tried, but I guess I didn't try it yet with this more simple ask, so it worked, thanks! I couldn't even figure this simpler version out after I was trying to update a larger part of the link, so I guess I should have asked my original question to solve for the entire path...do you know how I could replace "Group_Folder\Team Folder" with "GF_1\Team Folder (addme)"? It was the backslashes that seemed to original mess me up, but then I couldn't even get the version you showed to work for me, so I asked that one to see if it was something else.

Suggest an answer

Log in or Sign up to answer