The onle advice is to restore backup on test instance and get watchers list.
If you delete watcher for several users you can do it manually. If not - I could help you to write respective script.
I had around 300 scrs. For each SCR, watcher list was different. I wrongly updated each watcher list with some fixed names. I want to revert back to old one. It will be very helpful if some methods or scripts exist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The idea is following:
Here is code to get all watchers for specified issue list:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.watchers.WatcherManager import com.atlassian.jira.user.util.UserManager /** * Created by VZverev on 20.02.2016. */ //create a list of issues to get watchers List<Issue> issueList = new ArrayList<>(); issueList.add(ComponentAccessor.getIssueManager().getIssueObject("ZVER-3")) issueList.add(ComponentAccessor.getIssueManager().getIssueObject("ZVER-4")) UserManager userManager = ComponentAccessor.getUserManager(); //now lets find all watchers WatcherManager watcherManager = ComponentAccessor.getWatcherManager(); StringBuilder result = new StringBuilder(); for(Issue issue: issueList) { result.append("list.add(new AddWatchers(" + issue.getId() + ", [") for (String userKey : watcherManager.getWatcherUserKeys(issue)) { result.append( "\"" + userManager.getUserByKey(userKey).getKey() + "\", ") } result.append("])); ") } return result.toString().replace(", ]", "]")
You should run it via Script Console provided ScriptRunner plugin.
As result you will get strings to user in script for add watchers. Here it is:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.watchers.WatcherManager import com.atlassian.jira.user.util.UserManager /** * Created by VZverev on 20.02.2016. */ List<AddWatchers> list = new ArrayList<>() //Plave here all strings from previous script list.add(new AddWatchers(24910, ["vzverev@phosagro.ru"])); //Loop to add watchers for(AddWatchers addWatchers: list){ addWatchers.doSetWatchers(); } class AddWatchers{ Issue issue; List<String> watchersUserKeys; private static WatcherManager watcherManager = ComponentAccessor.getWatcherManager(); private static IssueManager issueManager = ComponentAccessor.getIssueManager(); private static UserManager userManager = ComponentAccessor.getUserManager(); public AddWatchers(long _key, List<String> _users ){ issue = issueManager.getIssueObject(_key); watchersUserKeys = _users; } public doSetWatchers(){ for(String user: watchersUserKeys) watcherManager.startWatching(userManager.getUserByKey(user), issue) } }
I strongly reccomend you to test it ar first on test instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.