Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create issues from xml with attachments?

Tony Montana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2019

All Hello.

 

We have MS system with HR issues. We want moving this issues with attachments in JIRA. We can generate CSV file in format JIRA.

 

But, how move attachements?

 

Example from CSV

04/Mar/19 12:00;ape988955_;CV_Ivan_Ivanov.pdf;https://jira.host.net/secure/attachment/36608/CV_Ivan_Ivanov.pdf

But attachs dont create, why?

 

1 answer

1 accepted

0 votes
Answer accepted
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2019

Hi Viktar,

The attachment cannot be imported because the URL is not publicly accessible when using a hosted location for the attachment URL the file is on a system that cannot be accessed by the destination system (exe: it requires a login to access the image)

When you upload to your files to the new server at $JIRA_HOME/import/attachments folder on the destination system you want to use FILE protocol and not the URL to another server or cloud site where the image is publicly hosted.   The URL option is used when you have an alternate system still hosting the images that can be referenced to pull the file across noting the location must be accessible by the destination system directly without any permission redirects. 

This is covered in the CSV import documentation "Importing data from CSV":

(info) URLs for attachments support the HTTP and HTTPS protocols and can be any location that your JIRA server must be able to access. You can also use the FILE protocol to access files in the import/attachments subdirectory of your JIRA home directory.

The FILE protocol is initiated with "FILE://" and uses the relative path to the file based off of $JIRA_HOME/import/attachments base directory,  So using your example URL and file name use this format and you should be good to go:

"file:///36608/CV_Ivan_Ivanov.pdf"

If you have a lot of files in your CSV that you are moving in one go rather than modifying each one individually the following KB article gives a search and replace command to convert the URL to to FILE protocol using sed that will do this for the full file:

Append the attachments URL in the CSV file, to FILE protocol using sed. Carefully replace <jira-base-url> in the command below, with the actual base URL of the source Jira. Appending the CSV file named import.csv:

sed -E 's@;<jira-base-url>/secure/attachment/([^/"])/.,@;file://\1,@' import.csv > new_import.csv

Regards,
Earl

Tony Montana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 2, 2019

@Earl McCutcheonThank you for the answer.

Can I use with file://  local PC path or no?

Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 3, 2019

Hi,

It's not possible to look in an alternate location. This is the path where Jira is looking for attachments when you specify:

file://example.png

It's looking for the relative path in your Jira home as the base location and translates to:

$path/to/jira-home/import/attachments/example.png

Regards,
Earl

Like Tony Montana likes this
Tony Montana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 3, 2019

Thank you very much!

Like Earl McCutcheon likes this

Suggest an answer

Log in or Sign up to answer