简体   繁体   English

如何通过Java代码将任何文件作为附件添加到JIRA问题?

[英]How to attach any file as an attachment to a JIRA issue by java code?

Any Ideas on how to programatically attach a File to an issue in JIRA? 关于如何以编程方式将文件附加到JIRA中的问题的任何想法? I need java code which should be called at end of my code so that it can upload my report files to an existing issue automatically... 我需要在代码末尾应调用的Java代码 ,以便它可以将我的报告文件自动上传到现有问题...

Im new to JIRA... 我是JIRA的新手...

从jira 5.x开始不推荐使用MangaerFactory,所以很好用

AttachmentManager attchMgr = ComponentAccessor.getAttachmentManager();

The AttachmentsManager can be used to attach a JAVA File object to a JIRA issue. AttachmentsManager可用于将JAVA File对象附加到JIRA问题。

import java.io.File;
import com.atlassian.jira.issue.AttachmentManager;
import com.opensymphony.user.User;
import java.util.HashMap;
import java.sql.Timestamp;
import com.atlassian.jira.issue.history.ChangeItemBean;
...
File file = new File(FILE_PATH);
AttachmentManager attachmentManager = ManagerFactory.getAttachmentManager();
ChangeItemBean changeItemBean = attachmentManager.createAttachment(file, file.getName(), "text/plain", user, issue.getGenericValue, new HashMap(), timestamp);

Source: http://docs.servicerocket.com/pages/viewpage.action?pageId=1711 来源: http : //docs.servicerocket.com/pages/viewpage.action?pageId=1711

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM