"Clones an issue and links" does not clone attachments

The built in ScriptRunner Script "Clones an issue and links" doesn't clone the attachments of the original Issue.


I'm using the following "Additional issue actions" to dynamically set the "Target Project" according to a predefined custom field:

import com.atlassian.jira.component.ComponentAccessor
issue.setProjectObject(ComponentAccessor.getProjectManager().getProjectObjByName(sourceIssue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Linked Project")).getValue()))
checkLink = {link -> false}
checkAttachment = {attachment -> true}

Setting the Target Project works fine, only Problem is that attachments won't be cloned.

3 answers

Does it work if you don't change the project?

Have you checked the logs, it looks like the following lines of your code are not valid:


Thanks for your fast reply, I did some more testing and was able to gather the following further info:

  • The issue is not caused by the issue.setSecurityLevelId() and issue.setAssigneeId() statements - these do in fact work and set these Fields to NULL.
  • The issue is not caused by my issue.setProjectObject() Statement
  • Cloning of Attachments does work in a different (Test) Project using the same Workflow(functions).
  • The issue seems to be related to the originating project beeing a "JIRA Service Desk" - There are plenty of small changes to the way Issues work in there.
  • I get the following Message in my logs when the Problem occurs. 

    WARN /secure/CommentAssignIssue.jspa [jira.workflow.postfunctions.CloneIssue] Attachment file does not exist where it should. Not copying.

Maybe this is related to more restrictive Permissions in effect for the Service Desk Project?


I was able to hunt down the root cause myself:

The project in Question has a changed project key. As documented the attachments will still be stored using the original project key.

This part in your "copyAttachments" function is wrong:

def filePath = PathUtils.joinPaths(pathManager.attachmentPath, issue.projectObject.key, issue.key, attachment.id.toString())

It should be refering to "originalKey" for both project and issue key.


Can this please be fixed?

Thanks for that, I created https://jamieechlin.atlassian.net/browse/GRV-556 - please watch for updates.

Hi Jamie Have you had a chance to look at this one? I just realised that is why our attachments have stopped copying on a clone action

I have not... but it seems easy enough to solve. I will try to get to it, but no plans for a new release for a few weeks.

Hi Jamie, Did this fix make it into 4.1 in the end? Cheers

Sorry, it did not. But I've made and tested the changes now and it will go into the next version: https://jamieechlin.atlassian.net/browse/GRV-806. Will release next week.

Fantastic! Thanks for that

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

441 views 8 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you