如何使用Java在Jira中使用atachments创建新的tack?
我想在Jira中创建带有附件的新任务。所以我试着:如何使用Java在Jira中使用atachments创建新的tack?,java,jira,Java,Jira,我想在Jira中创建带有附件的新任务。所以我试着: BasicCredentials creds = new BasicCredentials("username", "password"); JiraClient jira = new JiraClient("https://url", creds); try { File file1 = new File("D:\\image1.jpg"); File file2 = new File("D:\\des
BasicCredentials creds = new BasicCredentials("username", "password");
JiraClient jira = new JiraClient("https://url", creds);
try {
File file1 = new File("D:\\image1.jpg");
File file2 = new File("D:\\description.pdf");
List<File> fileList = new ArrayList<File>();
fileList.add(file1);
fileList.add(file2);
Issue newIssue = jira.createIssue("ProjectName", "Task")
.field(Field.SUMMARY, "Task with attachments")
.field(Field.DESCRIPTION, "Description for task with attachments.")
.field(Field.PRIORITY, Field.valueById("2"))
.field(Field.ATTACHMENT, fileList)
.execute();
} catch (JiraException e) {
e.printStackTrace();
}
但这种方式是错误的。如何将文件列表包括到Jira任务中?解决方案之一:
BasicCredentials creds = new BasicCredentials("username", "password");
JiraClient jira = new JiraClient("https://url", creds);
try {
File file1 = new File("D:\\image1.jpg");
File file2 = new File("D:\\description.pdf");
List<File> fileList = new ArrayList<File>();
fileList.add(file1);
fileList.add(file2);
Issue newIssue = jira.createIssue("ProjectName", "Task")
.field(Field.SUMMARY, "Task with attachments")
.field(Field.DESCRIPTION, "Description for task with attachments.")
.field(Field.PRIORITY, Field.valueById("2"))
.execute();
newIssue.addAttachment(file1);
newIssue.addAttachment(file2);
} catch (JiraException e) {
e.printStackTrace();
}
什么是JiraClient?我在JIRA API中没有看到它:@VolodymyrKrupach JiraClient您最好联系API的作者。在github页面上,我看到了一个示例:/*添加附件*/File File=new FileC:\\Users\\John\\Desktop\\screenshot.jpg;issue.addAttachmentfile;之后,您可能需要调用update方法。