I need a script for a post function to add mutliple users as watchers of a specific issue type when ticket created. I am currently on Server version of Jira but moving to Data Center, so I need script for both environments.
I will be in the same migration boat for Server to DC and my understanding is that most scriptrunner standard script implementations will be identical between the two environments.
Most jira admin would agree with the philosophy of avoiding setting other users as watchers. Invariably, someone will come around to ask why they were added as a watcher to a ticket which they did not want to watch.
You can achieve similar notification objectives by adjusting your notification scheme using a specific role.
But that being said, I know notifications can't be issue type-specific, and there are cases where this standard philosophy can justifiably be overruled.
A script like this may work for you
import com.atlassian.jira.component.ComponentAccessor
def issueTypeWatchers = [
'Bug': ['user1','user2'],
'Story': ['user2', 'user3']
]
issueTypeWatchers[issue.issueType.name].each{userName->
def user=ComponentAccessor.userManager.getUserByName(userName)
user && ComponentAccessor.watcherManager.startWatching(watcher, issue)
//user && ... will ensure that the user was valid before attempting to add as watcher
}
Put this as a custom post-function script at the end of all the post functions.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.