You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
hi,
I would like to use an issue manage an user-group.
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import java.util.List;
log.setLevel(org.apache.log4j.Level.DEBUG);
def groupManager = ComponentAccessor.getGroupManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def eventTypeManager = ComponentAccessor.getEventTypeManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changes = changeHistoryManager.getAllChangeItems(issue)
def eventTypeName = eventTypeManager.getEventType(event.eventTypeId).getName()
log.debug("EVENT TYPE NAME --> "+ eventTypeName)
def members_cf = customFieldManager.getCustomFieldObjectByName("members")
List<ApplicationUser> members = issue.getCustomFieldValue(members_cf)
log.debug "members:" + members
def groupName = issue.getSummary()
log.debug "groupName:" + groupName
if (issue.getIssueType().name == 'groupName') {
if (groupManager.groupExists(groupName)) {
// DeleteGroup(groupName)
}
if (issue.getStatus().name=='active'&&eventTypeName!='delete event') {
groupManager.createGroup(groupName)
def group = groupManager.getGroup(groupName)
log.debug "group:" + group
users.each { user -> groupManager.addUserToGroup(user, group) }
}
}
This line " // DeleteGroup(groupName)", how to do it.
Thanks
Hey @ninghongju
Welcome to Atlassian Community !!
Please check this script from adaptavist here https://library.adaptavist.com/entity/delete-groups-in-jira has an example of removing groups.
Also check this thread here this might help https://community.atlassian.com/t5/Jira-questions/Bulk-delete-groups-in-JIRA-using-Scriptrunner/qaq-p/1098530
Regards,
Vishwas
it's worked! Thanks so much!
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.crowd.embedded.core.util.StaticCrowdServiceFactory
def groupManager = ComponentAccessor.getGroupManager()
def crowdService = StaticCrowdServiceFactory.crowdService
def group = groupManager.getGroup('groupName')
crowdService.removeGroup(group)
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.