How to make an attachment internal in Jira?

Originally asked by kevin keovilay on 02 March 2021 (original question)


Hi,

I have been trouble to find how to make an attachment internal in Jira.

When synchronizing from AZD to Jira, only my comments are made private, but if there was attachments, they are made publics in Jira.

For the comment, it is documented and I have been doing the following :

issue.comments       = commentHelper.mergeComments(issue, replica, {it.internal = true; it})

But for Attachment, it seems there is no way to apply an internal field.

issue.attachments = attachmentHelper.mergeAttachments(issue, replica)

Sincerely,

Kévin


Answer by Ariel Aguilar on 03 March 2021

Hi Kevin,

You may want to change the attachments script to:

replica.attachments = issue.attachments.findAll { a ->
  def isMentionedInPublicComments = replica.comments.any {
    c -> c.body.contains("[^" + a.filename + "]") ||
        (c.body =~ (/!${java.util.regex.Pattern.quote(a.filename)}(\|.*!|!)/.toString())).find()
    }
  isMentionedInPublicComments
}

Kind regards,

Ariel