How to get a list of all attachments for Jira or Confluence

Description

For administrators, it is nice to be able to get a handle on attachments for Jira or Confluence. Both Jira and Confluence support the getAttachmentList action that normally gets attachments for a single entity (Jira issue or Confluence space). This describes how to do the same thing across the entire product.

Scale

Be careful on larger instances as this could take a significant amount of time and resources. You might want to consider splitting up your request or running during off hours. You may need more Java memory for running the client.

Steps for Confluence

Confluence is easy. 

–action getAttachmentList --outputFormat 2 --space @all --file list.csv

Steps for Jira

Jira is a bit more involved because it needs to deal (potentially) with a large number of issues and the limitations Jira has for listing issues with JQL. If you have more than 1000 issues, you can split up your request to only deal with less than 1000 issues at a time. You will need to do something like the following:

  1. Create a filter that returns all issues. Let's call it all, for example.
  2. Make this filter is marked as a Favorite for the user that will be running the action.
  3. Delete or clear the output file. Let's call it list.csv, for example.
  4. Run the following:

    --action runFromIssueList --filter all --common "--action getAttachmentList --outputFormat 2 --issue @issue@ --file list.csv --append"

Why is this needed?

  • Only Favorite filters can be accessed remotely.
  • Filters can be used remotely for paging requests so that more than 1000 issues can be handed.

Steps for Jira - alternative 

If each project you have has less than 1000 issues, then you can get away with something more simple by splitting up the request by project.

  1. Delete or clear the output file. Let's call it list.csv, for example.
  2. Run the following: 

    --action runFromProjectList --common "--action runFromIssueList --search ""project = @project@"" --common ""--action getAttachmentList --outputFormat 2 --issue @issue@ --file list.csv --append"" "

See Tips for quoting rules.