Hello @Andrew Striletskyi
You can use IssueFactory fow that
https://docs.atlassian.com/software/jira/docs/api/7.1.9/com/atlassian/jira/issue/IssueFactory.html
Yes , I know about. I have a situation when I want to create another issue. For example
def artifactIssue = issueManager.getIssueObject("TEST-2999")
def newArtifactIssue = issueFactory.cloneIssue(artifactIssue)
But It's not cloning an issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
clone issue just clone issue object, you need to create it after.
And for some reason it dont clone info about parent object, so you need to do that too.
Here the script:
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subtaskManager = ComponentAccessor.getSubTaskManager()
def issue = issueManager.getIssueObject("TEST-1")
log.error("SOURCE ISSUE KEY: ${issue.getKey()}")
def toclone = issueFactory.cloneIssueWithAllFields(issue)
def cloned = issueManager.createIssueObject(issue.reporter, toclone)
def parent = issueManager.getIssueObject(subtaskManager.getParentIssueId(issue))
subtaskManager.createSubTaskIssueLink(parent, cloned, issue.reporter)
log.error("CLONED ISSUE KEY: ${cloned.getKey()}")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes , It's OK for me. But last question: how to clone all subtasks of this issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Like this
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subtaskManager = ComponentAccessor.getSubTaskManager()
def issue = issueManager.getIssueObject("IM-474172") // parent issue
log.error("SOURCE ISSUE KEY: ${issue.getKey()}")
def subtasks = issue.getSubTaskObjects()
if (subtasks)
{
subtasks.each {subtask ->
def toclone = issueFactory.cloneIssueWithAllFields(subtask)
def cloned = issueManager.createIssueObject(issue.reporter, toclone)
subtaskManager.createSubTaskIssueLink(issue, cloned, issue.reporter)
log.error("CLONED ISSUE KEY: ${cloned.getKey()}")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You re welcome!
If it helps you, please mark answer as accepted :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have created a new ticket using the code above and it got created successfully. But the issue is that new request is getting created with the created date of parent ticket. Is there any way the created date can be changed to current date?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use the above code as well. But is there a way to return the sub-tasks in the order in which they're placed in the to-be-cloned issue? Because for us, order matters in terms of the order in which you execute sub-tasks, and that order is lost when cloning sub-tasks.
It looks like they're returned to the caller in the order in which they were created, not the order in which they were placed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.