The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Jira Automation - Regex Not Working for Deleting Attachments

adam.carter
Contributor
June 2, 2023

Hi there,

Hope somebody can help as I am struggling to get an automation to work. It's not a particularly tricky one; when an issue transitions to done, if a certain field is not empty, delete all attachments that start with the string "Data Privacy".

JiraAutomation.PNG

Automation triggers fine, if condition matches but the attachments are not deleted.

I've tried variations of the regex as I am not a regex master by any stretch but online tools suggest they would all work:

  • "^Data Privacy*"
  • "Data Privacy*"
  • Data Privacy*
  • Data*

I've output the names of the attachments in a comment using another Jira automation to try and prove that the automation is seeing the filenames as I see them:
JiraComment.PNG

I've set the rule to delete all attachments instead and that did work.

Here's the audit log of the last run:
JiraAuditLog.PNG

Any, and all, help greatly appreciated.

Many thanks

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Mikael Sandberg
Community Champion
June 2, 2023

My guess it that the regex for the file name needs to match the whole name, so try using this one and see if it works:

Data Privacy.*

adam.carter
Contributor
June 5, 2023

That did it, thank you Mikael!!

Like • Mikael Sandberg likes this
Jeremy Drexler
Contributor
November 1, 2023

@Mikael Sandberg looking to do something similar where we automatically delete .har files on ticket resolution in response to Hackers Stole Access Tokens from Okta’s Support Unit – Krebs on Security 

Also not a regex expert ... but our expectation was that this would work: \.har$

Any suggestions?har deletion rule.PNG

Like • Julia @ 55 Degrees likes this
Mikael Sandberg
Community Champion
November 1, 2023

@Jeremy Drexler It looks like the delete attachment step is not converting the $ regex correctly. I just tested and .*.har seems to work.

Jeremy Drexler
Contributor
November 2, 2023

It does! Thanks Mikael!

Like • Mikael Sandberg likes this
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events