Hello,
I am using Jira3.13, please help me to remove the bulk user from a particular group.
I have created the following jelly script, which is running without error however group is not removed from the profile.
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib">
<jira:RemoveUserFromGroup
name="argulwaa" groupname = "FO (FX)"/>
</JiraJelly>
Thanks in adavcne!
Regards,
Arpita Argulwar
there is no jelly tag which can remove users from group ... rather you can remove user completely using jelly.
refer jelly tags at https://confluence.atlassian.com/display/JIRA/Jelly+Tags
You can use following groovy script which checks and disable users and then removes a user from all groups .. you can customize it according to your requirements:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.security.GlobalPermissionManager
import com.atlassian.jira.security.Permissions
import com.atlassian.jira.security.roles.actor.UserRoleActorFactory
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.util.SimpleErrorCollection
import org.apache.log4j.Category
import com.atlassian.jira.project.Project
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.Group
import org.apache.log4j.Level
import org.apache.log4j.Logger
// Configurable section
isPreview = false
// End
Logger log = Logger.getLogger("********* User **********");
log.setLevel(Level.DEBUG)
// Separating Log from other
log.debug("##########################################################".toString())
log.debug("##########################################################".toString())
log.debug("##########################################################".toString())
userManager = ComponentManager.getInstance().getComponentInstanceOfType(UserManager.class)
GlobalPermissionManager globalPermissionManager = (GlobalPermissionManager) ComponentManager.getInstance().getComponentInstanceOfType(GlobalPermissionManager.class)
def deactivateUser (User user) {
log.debug ("deactivateUser ${user.getName()}")
// Remove user from all groups...
UserUtil userUtil = ComponentManager.getInstance().getUserUtil()
userManager.getGroups().each {
Group group = userManager.getGroupObject(it.getName())
log.debug ("Remove ${user} from group: ${group}")
if (! isPreview) {
userUtil.removeUserFromGroup (group, user)
}
}
// Remove user from all roles...
ProjectRoleService projectRoleService = (ProjectRoleService) ComponentManager.getComponentInstanceOfType(ProjectRoleService.class);
SimpleErrorCollection errorCollection = new SimpleErrorCollection();
log.debug ("Removing all roles references for ${user.getName()}")
projectRoleService.getProjectsContainingRoleActorByNameAndType(userManager.getUser("admin"), user.getName(), UserRoleActorFactory.TYPE, errorCollection).each {Project project ->
log.debug ("Remove user ${user.getName()} from role: ${project.getName()}")
}
if (! isPreview) {
projectRoleService.removeAllRoleActorsByNameAndType (userManager.getUser("admin"), user.getName(), UserRoleActorFactory.TYPE, errorCollection)
}
}
Integer i=0
userManager.getUsers().each {it->
name=it.getDisplayName()
//log.debug ("username ::: ${user}")
//log.debug ("name ::: ${name}")
if (!it.isActive()) {
log.debug ("User: ${it} should be retired")
deactivateUser (it)
i++
}
}
log.debug ("Total ${i}")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.