Import attachments after initial import

About a month ago I imported a bunch of issues to a 5.2.11 Jira using CSV. It turns out that there were attachments that should have come with those issues. So I am now hoping to update all the imported issues, adding the appropriate attachments.

Things I can do/have done:

-Put all the attachments in <JIRA HOME>/import/attachments/

- Set up the CSV file so that each issue has a line including issuekey, summary, list of attachments in format "date;user;file://filename_on_disk" (as described in https://confluence.atlassian.com/display/JIRA/How+to+import+attachment+using+CSV)

However, it says here (https://confluence.atlassian.com/display/JIRA/Importing+Data+From+CSV#ImportingDatafromCSV-Updatingexistingissues) that this will blow away all other fields of the issues. Is this really true? It doesn't/I can't tell it to leave other fields as-is?

Do I have to dump all the existing data for these issues, include it all in my CSV, and re-import it all? That seems crazy. Is there a way to make these kind of bulk updates?

I'd appreciate any help! Thanks

3 answers

1 accepted

This widget could not be displayed.

Ok, Thanks for the suggestions, but it turns out the Jira REST API can do this, which avoids:

-having to dump and entire project, fiddle with the data, and reimport (which is super prone to errors)

-buying a third-party plugin


Here's the page that describes it:
https://confluence.atlassian.com/display/JIRA/How+to+attach+an+attachment+in+a+JIRA+issue+using+REST+API

After creating a .csv file that matched up the issues with the attachments I wanted in each, I wrote a simple bash script that ran through the file and called that curl command for each line, of the form:

inputFile="$1"
while IFS="," read filename issuekey
    do 
	curl -D- -u user:password -X POST -H "X-Atlassian-Token: nocheck" -F "file=@path/to/local/$filename" http://JIRA_BASE_URL:8080/rest/api/2/issue/$issuekey/attachments
done &lt; $inputFile
echo "done"

Hopefully that helps anyone looking to do this in the future...

This widget could not be displayed.

Hi Ryan

Re-importing a csv on the same project will wipe off all existing data.

What i suggest you is take export of existing data in a csv, add the attachment information and import it back on a separate project.

Rahul

Tim Evans Atlassian Team Jan 16, 2015

In this case Ryan is not importing data from a CSV file. The CSV contains the filenames and issuekeys and is used by the script to add attachments to existing issues using the REST API.

This widget could not be displayed.

Another option is to just add the attachments to the existing issues. Especially better if you have active users as this can be done while active. You could create a file (with actions) with the specific attachment details and use the run action or use runFromCsv explained here: How to use runFromCsv . In either case, the critical action you need is addAttachment .

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

232 views 3 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you