Skip to content

Instantly share code, notes, and snippets.

@hfs
Created March 23, 2017 11:19
Show Gist options
  • Save hfs/d5db88cbff1f6a4471f8399389ca91e0 to your computer and use it in GitHub Desktop.
Save hfs/d5db88cbff1f6a4471f8399389ca91e0 to your computer and use it in GitHub Desktop.
JIRA: Unwatch all issues
#!/usr/bin/env python
import json
import requests
JIRA_URL = 'https://JIRA base URL' #Fill in your JIRA Root
WebSession = requests.Session()
WebSession.auth = ('username','password') #JIRA Credentials go here, Optionally use Base64 Encode/Decode
WebParams = {'jql':'watcher = currentUser()', 'fields':'key,summary', 'maxResults':'9999'} #You can use basically any JIRA search query here in the JQL parameter
WatchList = WebSession.get(JIRA_URL + '/rest/api/latest/search', params=WebParams)
WebParams = {'username': 'username'} #Insert User Name of watcher to delete here, probably yours
for k in WatchList.json()['issues']:
print 'Removing Watcher ' + WebParams['username'] + ' from issue ' + k['key'] + ': ' + k['fields']['summary']
WebSession.delete(JIRA_URL + '/rest/api/latest/issue/'+k['key']+'/watchers', params=WebParams)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment