...
Description
For release 3.3 and above, getAttachmentList and runFromAttachmentList actions provide a lot of flexibility to find and do actions on a set of attachments determined by various conditions. One of the primary use cases is to remove attachments.
- Condition on what content contains the attachments
- By space - all content in a space. Use the space parameter.
- By page - a specific page identified by space and title or id (content id).
- By search conditions similar to the UI search screen - see Searching Confluence:
- search - search text
- searchTypes - what type of content to search, it this case only page and blogpost apply
space - where to restrict seach
- userId - restrict to a content created by a specific user
- Condition on the name of the attachments to be listed or acted on - regex is a regex match string on the attachment name
Steps
- Determine the content condition you need. If it is a search, first use getContentList to verify that the search conditions result in the right set of pages.
- Determine the attachment name condition.
- Use getAttachmentList to list the attachments found by your criteria to verify the right set of attachments are found.
- Use runFromAttachmentList with the same parameters and specifying a common action of removeAttachment using the appropriate replacement variables.
Example
Here is a simple example used on this site for clean-up.
No Format | ||
---|---|---|
| ||
confluence --action getAttachmentList --space info --title downloads --regex ".*-SNAPSHOT.*" |
No Format | ||
---|---|---|
| ||
confluence --action runFromAttachmentList --space info --title downloads --regex ".*-SNAPSHOT.*" --common '-a removeAttachment --id @pageId@ --name "@attachment@"' |