Created
June 20, 2018 12:58
-
-
Save sd65/c4f69202c11666ba6fe421064dbbae54 to your computer and use it in GitHub Desktop.
Delete attachements from a Confluence page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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