I'm searching for a solution that gives me an opportunity to add the user from Custom Field to specific JIRA Group by a post-function workflow or a listener.
I saw solutions like the following example in the community, but this does not seem to work anymore; the addUserToGroup method is not recognized.
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def user = "Neuling"
def group = groupManager.getGroup("Group1")
groupManager.addUserToGroup(user,group)
Thanks in advance!
Hi @Sngy ,
Kindly check this link for script to remove users from group
https://library.adaptavist.com/entity/remove-specified-users-from-a-group
Replace "removeUserFromGroup" with "addUserToGroup" and "userToRemove" with "userToAdd". It should work
This might help....
import com.atlassian.jira.component.ComponentAccessor
def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
final String groupName = "GROUPA" // the group you want to add users
def group = ComponentAccessor.groupManager.getGroup(groupName) // user names of the users to add
final List<String> userToAdd = ["USR1", "USR2", "USR3"]
userToAdd.each {
def usertoadd = userManager.getUserByName(it)
if (!usertoadd) {
log.warn("User: $userToAdd doesn't exist")
return
}
if (ComponentAccessor.getGroupManager().getGroupsForUser(usertoadd).contains(group)) {
log.warn("User: $usertoadd.username already in the group: $groupName")
return
}
if(!group) {
log.warn("Group: $groupName doesn't exist")
} else {
userUtil.addUserToGroup(group, usertoadd)
log.warn("User: $usertoadd.username added to the $groupName")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vijay,
I want to check if the "Jira-users" group is used in the notification scheme or not.
If yes then send an email.
Can you please help me in that
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.