Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Clone issue with comments in script runner for jira cloud

Hi All,

I am I am using jira cloud and script runner for jira.

When I tried to clone from post function with script runner Comments were not getting cloned. 

I tried

but no luck.

Thanks in advance



4 answers

1 accepted

3 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 11, 2019

Hi Pooja,

I can confirm that you have linked to above will not work inside of ScriptRunner for Jira Cloud is due to the fact the code you have provided is fro ScriptRunner for Jira Server and this will not work as Atlassian only provide a rest API in Jira Cloud and do not provide a Java API in the cloud like they do in Jira Server.

You can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.

I can also confirm that it is not possible to copy comments using the Clone Issue post function inside of Jira Cloud due to the restricted nature of Jira Cloud which means that it is not possible to copy the issue and its comments at the same time.

This means that you will need to use a seperate approach such as writing a custom script to copy the issue which can use the Get Comments and Add Comment API's to copy the comments between issues.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



If you want a custom script I can share my code :)

I really need this, so I would love to get your custom script!

i need this script as well :)

import org.apache.log4j.Logger
import groovy.json.JsonSlurper
def log = Logger.getLogger("com.acme.workflows")

//Wybieramy pole z project picker
def customFieldName = 'customfield_10036'

//wyciagamy pola
def fields = get("/rest/api/2/issue/${issue.key}?fields")
.header('Content-Type', 'application/json')

def projectKeyFromField = fields.customfield_10036.key
def selectedFields = fields.customfield_10037.value as List
def summary = fields.summary
def components =
def reporter = fields.reporter
def labels = fields.labels
def assignee = fields.assignee
def comment = fields.comment
def attachment = fields.attachment
def subtasks = fields.subtasks
def originalKey = issue.key


//def projectKey = projectKeyFromField
def projectId = get("/rest/api/2/project/${projectKeyFromField}").asObject(Map)
// Wyszukujemy ID typu taska
def taskType = get("/rest/api/2/issuetype/project?projectId=${projectId}").asObject(List).body.find { it['name'] == 'Zadanie' }['id']
//Tworzymy zgłoszenie
def postedIssue = post('/rest/api/2/issue')
.header('Content-Type', 'application/json')
fields: [
summary : summary,
description: "Test",
labels : labels,
reporter : reporter,
assignee : assignee,
components : [{
id : components}
project : [
key: projectKeyFromField
issuetype : [
id: taskType


def createdIssueKey = postedIssue as String
for(int i = 0; i < fields.comment.comments.body.size(); i++){
post('/rest/api/2/issue/' + createdIssueKey + '/comment')
.header('Content-Type', 'application/json')
body : fields.comment.comments.body[i],
author: [

//wrzucamy zalaczniki
for(int i = 0; i < attachment.size(); i++ ){
def attId =[i]
def att = Unirest.get('/rest/api/2/attachment/' + attId).asObject(Map).body
def downloadUrl = attachment.content[i]
def readFileResp = Unirest.get(downloadUrl).asBinary()
def response ='/rest/api/2/issue/' + createdIssueKey + '/attachments')
.header("Accept", "application/json")
.header("X-Atlassian-Token", "nocheck")
.field("file", readFileResp.body, att.title.toString())


//id subtaska
def subTaskType = get("/rest/api/2/issuetype/project?projectId=${projectId}").asObject(List).body.find { it['name'] == 'Podzadanie' }['id']

//sprawdzmay czy są subtaski, jeśli tak - są przenoszone
if(subtasks != null){
for(int i = 0; i< subtasks.size(); i++){
.header('Content-Type', 'application/json')
fields: [
summary : subtasks.fields.summary[i],
description: subtasks.fields.description[i],
reporter : reporter,
assignee : assignee,
parent : [
key : postedIssue
project : [
key: projectKeyFromField
issuetype : [
id: subTaskType

//Linkowanie zgloszen
// Specify the source issue
def soucrceIssueKey = "TS-2"
// Specify the target issue
def targetIssueKey = "TS-3"

// Spcecify the link type to use
def linkType = "Duplicate"

// Create the issue link between both issues
def link = post('/rest/api/3/issueLink')
.header('Content-Type', 'application/json')
type: [ name: linkType ],
outwardIssue: [ key: originalKey ], // This is the issue that the link 'starts' at.
inwardIssue: [ key: createdIssueKey ] // This is the issue that the link 'finises' at.
// validate that the issue link created correctly

// Validate the issue updated correctly
if (link.status == 201) {
return "Success - The issues with the key of ${soucrceIssueKey} and ${targetIssueKey} have been linked with the ${linkType} link type."
} else {
return "${link.status}: ${link.body}"
Like Tomasz Osik likes this

Hi Lukasz

I owe you a big bottle of "Zoladkowa Gorzka" (or any other vodka :) )

Here to help, just check if it's work, I've created it some time ago :) 

Carney Calcutt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Oct 10, 2023

I have also run into this same issue. We are currently cloning an issue as Workflow Post Function. I am very new to all of this. Where does this script go?

My code is for cloud, works as a postfunction

Is there a way to clone issue comments in Jira Next Gen (cloud)?

0 votes
Marlene Kegel - codefortynine
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Mar 13, 2019

If you don't want to write a custom script you can try our cloud app Deep Clone for Jira. With that app you can clone comments and other advanced content.

It's also possible to bulk clone thousands of issues and move them in one go.



But is it possible to deep clone it with Jira Automation?

Marlene Kegel - codefortynine
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Mar 21, 2022

If you want to trigger a clone from post-function, you can work with the Deep Clone workflow post-function.

If you want to trigger a clone with Jira Automation, but don't want to change the status, you can work with a looping transition and a Deep Clone post-function.

If you want to trigger an automation from a Deep Clone you can create an incoming webhook.

Suggest an answer

Log in or Sign up to answer