Skip to content

Instantly share code, notes, and snippets.

@sd65
Created June 20, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sd65/c4f69202c11666ba6fe421064dbbae54 to your computer and use it in GitHub Desktop.
Save sd65/c4f69202c11666ba6fe421064dbbae54 to your computer and use it in GitHub Desktop.
Delete attachements from a Confluence page
#/bin/bash
# $1 = pageid (obtained in URL)
# JIRA_USERNAME & JIRA_PASSWORD must be set
# Needs jq and curl to be installed
# Fill this (Confluence workspace name):
PROJECT_NAME=xxx
IFS=$'\n'
CURL() { curl -f -u $JIRA_USERNAME:$JIRA_PASSWORD https://$PROJECT_NAME.atlassian.net/wiki/rest/api/content/$@; }
for fields in $(CURL $1/child/attachment | jq -r '.results[] | [.id, .title] | join (";")')
do
id="${fields%;*}"
filename="${fields#*;}"
read -p "Do you wish to delete $filename? [y/(n)]" yn
case $yn in
[Yy]* ) CURL $id -X DELETE && echo "OK, deleted";;
* ) echo "OK." ;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment