By a bulk operation I'd like to add a watcher to a list of issues.
It seems I can only add myself as watcher to this list.
Is there a way to add others than myself?
@Paul van Erp You can use this script:
Just follow this steps:
~First change user and user2 (user2 is watcher)
~Second change query (JQL)
//-----------------------------------------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.ApplicationUser
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()
//EDIT THIS USER
def user = userManager.getUserByName("jamil.rahimov")
// Edit this query to suit
def query = jqlQueryParser.parseQuery("project = SD AND issuetype = \"Service Request\" AND status = \"In Progress\"")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
log.debug("Total issues: ${results.total}")
//TYPE WATCHER ID FOR ADDING TO THE ISSUE
ApplicationUser user2 = userManager.getUserByName("admin")
def watcherManager = ComponentAccessor.getWatcherManager()
results.getIssues().each {documentIssue ->
log.debug(documentIssue.key)
// if you need a mutable issue you can do:
def issue = issueManager.getIssueObject(documentIssue.id)
if (user2)
watcherManager.startWatching(user2, issue)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.