Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在jira(groovy)中从工作流转换屏幕访问附加文件_Groovy_Workflow_Jira_Transition - Fatal编程技术网

如何在jira(groovy)中从工作流转换屏幕访问附加文件

如何在jira(groovy)中从工作流转换屏幕访问附加文件,groovy,workflow,jira,transition,Groovy,Workflow,Jira,Transition,在工作流转换中,我有一个带有“附加文件”输入的屏幕。在post功能中,我希望访问附加文件(如果有),并将此文件作为附件创建另一个问题 我试图通过ServletActionContext.getRequest()实现这一点,但我似乎无法通过这种方式获得上传的文件。HttpServletRequest没有getPart()函数 是否有官方方式从post功能访问附件 事先非常感谢感谢内基帕的回答,我找到了一个有效的解决方案。以下是我的想法: // copy attachments uploaded i

在工作流转换中,我有一个带有“附加文件”输入的屏幕。在post功能中,我希望访问附加文件(如果有),并将此文件作为附件创建另一个问题

我试图通过ServletActionContext.getRequest()实现这一点,但我似乎无法通过这种方式获得上传的文件。HttpServletRequest没有getPart()函数

是否有官方方式从post功能访问附件

事先非常感谢

感谢内基帕的回答,我找到了一个有效的解决方案。以下是我的想法:

// copy attachments uploaded in screen to new issue
def changeItems = transientVars["changeItems"]
def uploadChanges = changeItems.findAll { item -> item.getField() == "Attachment" && item.getFieldType() == "jira" }

uploadChanges.each { uploadChange ->
  def Attachment attachment = attachmentManager.getAttachment(uploadChange.getTo()?.toLong())
  if (attachment) {
    def filePath = PathUtils.joinPaths(pathManager.attachmentPath, currentIssue.projectObject.key, currentIssue.key, attachment.id.toString())
    def atFile = new File(filePath)
    if (atFile.canRead()) {
        log.debug("Cloning attachment ${attachment.filename}")
        attachmentManager.createAttachmentCopySourceFile(atFile, attachment.filename, attachment.mimetype, attachment.author, newIssue, [:], attachment.created)
    }
  }
}
重要提示:问题保存到数据库后,必须执行脚本。否则,transientVars中没有更改项和/或附件未保存到磁盘。我把它移到了死刑执行的最后,对我来说效果很好