Example scripts
To homepage
Jira

Clone Issues or Parts of Issues in Jira
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.0 - 8.14)

ScriptRunner For Jira (6.18.0)
Language |
groovy
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
// the issue key of the issue to clone
final String originalIssueKey = "JRA-1"
// the summary of the new issue
final String newSummary = "A summary for the cloned issue"
// the empty map will clone all the custom fields from the original issue
final Map<CustomField, Optional<Boolean>> customFieldsToClone = [:]
final boolean cloneAttachments = true
final boolean cloneSubTasks = true
final boolean cloneLinks = true
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueManager = ComponentAccessor.issueManager
def issueService = ComponentAccessor.issueService
def originalIssue = issueManager.getIssueByCurrentKey(originalIssueKey)
def validationResult = issueService.validateClone(loggedInUser, originalIssue, newSummary, cloneAttachments, cloneSubTasks, cloneLinks, customFieldsToClone)
assert validationResult.valid : validationResult.errorCollection
def result = issueService.clone(loggedInUser, validationResult)
assert result.valid : result.errorCollection
Having an issue with this script?
Report it here