Command Line using Site Export

Kathleen Jacobs March 22, 2018

Trying to use Jira Command Line Interface to export old issues and attachments so I can save them compressed local and delete them from the server.  

Was wondering is the SiteExport command would work for this?

What all does it export and how would I access the data again if needed?  

 

1 answer

1 accepted

1 vote
Answer accepted
Bob Swift {Appfire} March 28, 2018

You can certainly use the CLI to export issues directly or via scheduled task. Use the getIssueList action to get CSV output. However, once you remove the issues from Jira, you are not going to be able to get them back in like they were originally. You are going to lose the same issue key, history, comments, the key, etc... . 

There is also an option on getIssueList to create/update a database table with the issue information. That makes it more readily available via SQL query. And if that is sufficient and you don't need to restore the data back into Jira, then that would satisfy your requirement. The key is knowing your exact needs wrt to the data once removed from Jira.

Site export is the exporting the entire site (just like from the UI) and that means it can only be restored in its entirety unless you muck with the XML - yuk! Jira has never support a export/import project capability.

There are some posts on this site regarding Jira archiving and some related tools.

Kathleen Jacobs March 28, 2018

Main thing I want to do is pull the attachments.  How are the attachments structured in this?  Are they in files based on the ticket number?  Really don't need any of the ticket information except a way to connect the attachments to a ticket, in case a user want's to look up attachments.

Doing the export, does it remove the tickets in jira or does it just make a copy?  

Bob Swift {Appfire} March 28, 2018

Ok, attachment is a different thing. No, export is simply a way to information out of the application. You need to do some form of a delete operation to remove things from the application.

If you want prune attachments from issues, then I recommend figuring out what your criteria is and then write a small script to implement your criteria by using getIssueList and getAttachmentList to loop through issues and attachments. Decide on each attachment based on the information provided. If you are going to prune an attachment, retrieve the data into a file using getAttachment and then removeAttachment.

Kathleen Jacobs March 28, 2018

That's what I'm currently doing.  I'm using --jql for a query on getIssueList for GetAttachmentList. Then removing them with removeAttachment as it reads the csv list. 

But trying to find a way to back them up before I delete them.  Archived locally to access if needed.  Was thinking ExportSite could do that?

Then the attachments will be removed but the tickets will stay.

Bob Swift {Appfire} March 29, 2018

Use getAttachment for each one before you delete it.

Jira export site does NOT do attachments. You need to backup attachments separately for nightly backups or for export. See the Jira backup instructions. The problem with this is the storage of the attachments and file naming is complex - just look at your attachments directory. So that is not viable without a lot of work.

Separately exporting (and tracking) each attachment you are pruning is what I recommend.

Kathleen Jacobs March 29, 2018

Thank you!

Currently I'm running this to pull the attachment list:

jira --action runFromIssueList --jql "project = 'projectNew' and NOT attachments is EMPTY AND updatedDate < '2018/01/01'" --common "--action getAttachmentList --issue @issue@ --file attachmentListNew.csv --outputFormat 999 --append


Trying to run this to pull the attachments but getting an error:

jira --action runFromCSV --file attachmentListNew.csv --common "--action getAttachment --issue @issue@"

Error:

Error: Parameter 'issue' cannot be declared more than once.

Kathleen Jacobs April 2, 2018

Any help with this error would be appreciated :)

I think this should handle the problem i'm trying to address.  

Bob Swift {Appfire} April 2, 2018

The CSV file already contains the issue parameter, so it is duplicated.

Kathleen Jacobs April 2, 2018

If I remove the -issue parameter i get the following error:

This function requires a non-blank value for parameter file.

Do i need to list the file twice?

Thought maybe it was asking for where to store the attachments?  But when I added a --file it tells me This function requires a non-blank value for parameter issue.

Same when i entered the same --file parameter, the csv,  twice

Bob Swift {Appfire} April 2, 2018

getAttachment needs the file parameter specified so it know where to put the attachment. I believe if you specify a existing directory, it will add it there.

Kathleen Jacobs April 2, 2018

Thank you! Fixed! 

Ross Dammann February 5, 2020

this is a somewhat related issue.

 

We would like to use CLI (which I believe will work from what I read), to automatically update issues and add new ones from a csv file. We have a csv file that gets dropped to our shared drive, and we want to be able to import that data to 1) update issues and 2) add new issues.

Can someone point me in the direction and/or confirm CLI would work for this?

thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events