簡體   English   中英

如何通過Java代碼將任何文件作為附件添加到JIRA問題?

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

關於如何以編程方式將文件附加到JIRA中的問題的任何想法? 我需要在代碼末尾應調用的Java代碼 ,以便它可以將我的報告文件自動上傳到現有問題...

我是JIRA的新手...

從jira 5.x開始不推薦使用MangaerFactory,所以很好用

AttachmentManager attchMgr = ComponentAccessor.getAttachmentManager();

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);

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM