Skip to content

Instantly share code, notes, and snippets.

@prenagha
Created July 12, 2012 15:33
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save prenagha/3098888 to your computer and use it in GitHub Desktop.
Save prenagha/3098888 to your computer and use it in GitHub Desktop.
JIRA Bulk Unwatch
#
# 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 "/jira/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
@benjambe
Copy link

Hi Padraic,

Just forked your script and pushed a change to fgrep "/browse/" instead of "/jira/browse/" as for example our JIRA at work doesn't have /jira/ in the URLs.
Totally new to Gist.
Is there such a thing as pull requests here?

@dcai
Copy link

dcai commented Jun 18, 2013

Well done, thanks

@nriahi
Copy link

nriahi commented Jul 19, 2013

Do you just run this script in Mac terminal? do you need any particular software installed?

@peterjenkins
Copy link

@benjambe Thanks so much for posting that comment!

@jschneider
Copy link

Today it is possible to just unwatch issues using bulk operations.
So just use the query as described above:

issue in watchedIssues()

And select bulk change.

@ccharlton
Copy link

This was my version, no script needed.

watcher = currentUser() AND resolution = Unresolved AND assignee != currentUser() ORDER BY priority DESC, updated DESC

@fshoorbajee
Copy link

This was my version, no script needed.

watcher = currentUser() AND resolution = Unresolved AND assignee != currentUser() ORDER BY priority DESC, updated DESC

This works 100% thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment