Created
June 12, 2017 13:56
-
-
Save jayotterbein/79fc361cb7a45b4b6b4b518d0642e9ab to your computer and use it in GitHub Desktop.
Unwatch everything in JIRA
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 | |
# Bulk Unwatch | |
# JIRA doesn't support unwatch from the bulk change action | |
# This script fills the gap | |
# Known to work with JIRA 5 via the REST API | |
# | |
# 1. Using JIRA, Issue Navigator, write a query to get all | |
# the issues you want to unwatch. Something like | |
# "issue in watchedIssues() AND status != Closed" | |
# works well as a starting point. | |
# 2. Using the View menu, Right-Click on RSS and save the RSS | |
# output to your computer. | |
# 3. Run this script against the RSS file you downloaded | |
# ./bulkUnwatch.sh <JIRA USERID> <JIRA PASSWORD> <RSS FILE> | |
# | |
USERID=$1 | |
PASSWORD=$2 | |
RSS=$3 | |
if [ -z "$USERID" -o -z "$PASSWORD" -o ! -f "$RSS" ] | |
then | |
echo "bulkUnwatch.sh <JIRA USERID> <JIRA PASSWORD> <RSS FILE>" | |
exit 1 | |
fi | |
for URLBASE in `cat $RSS | fgrep "<link>" | fgrep "/browse/" | sed 's/<link>//' | sed 's#</link>##' | sed 's#browse#rest/api/latest/issue#'` | |
do | |
# 204 response on success | |
URL="${URLBASE}/watchers?username=${USERID}" | |
curl --request DELETE \ | |
--write-out "%{http_code}\n" \ | |
--header "Accept: application/json" \ | |
--header "Content-Type: application/json" \ | |
--user "${USERID}:${PASSWORD}" \ | |
$URL | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment