Last active
September 7, 2017 16:16
-
-
Save fatbattk/7e2dd347d1611d8244823fdb55bb776b to your computer and use it in GitHub Desktop.
Mass unwatch issues in JIRA from your browser.
This file contains 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
// Unwatch all project issues for current logged in user. | |
// NOTE: There is a max 50 issue limit. Run multiple times to unwatch more. | |
// USAGE: | |
// - update vars below to target specific Project/Issue Status if desired. | |
// - log on to JIRA board on browser. | |
// - copy-paste entire code below into browser's dev console and run. | |
// - check found issues via console and confirm/cancel unwatching to finish. | |
(()=>{ | |
const project = '', // (optional) enter the exact project name to limit (e.g.- DC). | |
status = ''; // (optional) enter exact target issue status (e.g.- Closed/Complete/Done/Rejected). | |
let add_jql = ''; | |
if(project) add_jql += ' AND project="'+ project +'"'; | |
if(status) add_jql += ' AND status="'+ status +'"'; | |
AJS.$.ajax({ | |
url: '/rest/api/latest/search', | |
data: { jql:'watcher = currentUser()'+ add_jql }, | |
success: (response)=>{ | |
console.log('- Found:',response.issues); | |
if(confirm('Continue unwatching? '+ (response.total<=50? response.total:50) +' total found. Click cancel to abort.')){ | |
AJS.$.each(response.issues,(i,issue)=>{ | |
AJS.$.ajax({ | |
url: '/rest/api/1.0/issues/'+ issue.id +'/watchers', | |
type: 'delete', | |
success: ()=>console.log('- Unwatched: '+ issue.key) | |
}); | |
}); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment