I have this script taken from an example, but I can't find any documentation on any of the classes and can't figure out how to adapt it so that I can clone an issue to a new project without cloning/copying the Description field?
I see the "FIELD_SELECTED_FIELDS" input, but I can't find any examples of anyone ever using that to specify a select set of fields to clone, or to omit 1 specific field?
I need to omit the Description because it contains sensitive data, and it is not sufficient to delete the value after the clone because that sensitive data would still be in the issue's history. If there was some documentation on how to use the "FIELD_ADDITIONAL_SCRIPT" to redact information, then that would be an option, but again, no doco on any of this anywhere beyond a few nearly identical simple examples.
// def projectManager = ComponentAccessor.projectManager
def issueManager = ComponentAccessor.issueManager
def projectToCopyTo = projectManager.getProjectByCurrentKey(targetProjectKey)
def issueToCopy = issueManager.getIssueObject(originalIssue.key)
// Block creation of intra-project links
def blockIntraprojectLinks = '{l -> l.sourceObject.projectObject != l.destinationObject.projectObject}'
if (!issueToCopy) {
log.warn("Issue ${originalIssue.key} does not exist")
return
}
//Set the creation parameters/inputs (use clone issue but with no link type)
def inputs = [
(CloneIssue.FIELD_TARGET_PROJECT) : projectToCopyTo.key,
(CloneIssue.FIELD_LINK_TYPE) : null,
(ConditionUtils.FIELD_ADDITIONAL_SCRIPT): [
"checkLink = $blockIntraprojectLinks;",
""
],
(CloneIssue.FIELD_SELECTED_FIELDS) : null, // clone all the fields
(CloneIssue.SKIP_EPIC_LINKS) : "true",
] as Map<String, Object>
def executionContext = [issue: issueToCopy] as Map<String, Object>
def newClonedIssue = ScriptRunnerImpl.scriptRunner.createBean(CloneIssue)
// Execute the clone action with the specified inputs
def updatedExecutionContext = newClonedIssue.execute(inputs, executionContext)
//The issue has been successfully cloned
assert updatedExecutionContext.newIssue
targetIssue = Issues.getByKey(updatedExecutionContext.newIssue as String)
log.warn("targetIssue = ${targetIssue}")
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.