I need to add a new workgroup to approximatly 30 permission schemes to be able to edit and was wondering if there is a way to do it quickly other than having to go into each individual permission scheme and add them to edit.
Community moderators have prevented the ability to post new answers.
If you have or can install script runner, here is a script which adds the anyone group to every permission scheme for the VIEW_WORKFLOW permission. Perhaps you can modify it to suit your needs.
For some reason when this new permission was added by an upgrade, the upgrade task added no groups or roles to this permission.
package examples import com.atlassian.jira.ComponentManager import com.atlassian.jira.ManagerFactory import com.atlassian.jira.permission.PermissionSchemeManager import com.atlassian.jira.scheme.SchemeEntity import org.apache.log4j.Level import org.apache.log4j.Logger import org.ofbiz.core.entity.GenericValue import static com.atlassian.jira.security.Permissions.VIEW_WORKFLOW_READONLY Logger log = Logger.getLogger("OneOffAddViewWorkflowPermission"); log.setLevel(Level.DEBUG) PermissionSchemeManager permissionSchemeManager = ComponentManager.getComponentInstanceOfType(PermissionSchemeManager.class) permissionSchemeManager.getSchemes().each {GenericValue scheme -> if (ManagerFactory.getPermissionSchemeManager().getEntities(scheme, VIEW_WORKFLOW_READONLY, "group", null).isEmpty()) { log.debug("Modify scheme ${scheme.get('name')}".toString()) try { SchemeEntity schemeEntity = new SchemeEntity("group", null, VIEW_WORKFLOW_READONLY); permissionSchemeManager.createSchemeEntity(scheme, schemeEntity) } catch (Exception e) { log.warn ("Error updating scheme: ${scheme.get('name')}".toString()) } } else { log.debug("Scheme ${scheme.get('name')} already has an entry for this permission".toString()) } }
I don't quite have the Java chops for this, so maybe someone can help me...
I want to use Jamie's script or something like it, but I want to add the administrators group to various permissions from (https://docs.atlassian.com/jira/latest/com/atlassian/jira/security/Permissions.html) across all projects.
This would save me hours of clicking, so thanks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like I figured it out. This seemed to add "administrators" to the edit issues permission. package examples import com.atlassian.jira.ComponentManager import com.atlassian.jira.ManagerFactory import com.atlassian.jira.permission.PermissionSchemeManager import com.atlassian.jira.scheme.SchemeEntity import org.apache.log4j.Level import org.apache.log4j.Logger import org.ofbiz.core.entity.GenericValue import static com.atlassian.jira.security.Permissions.EDIT_ISSUE Logger log = Logger.getLogger("OneOffAddViewWorkflowPermission"); log.setLevel(Level.DEBUG) PermissionSchemeManager permissionSchemeManager = ComponentManager.getComponentInstanceOfType(PermissionSchemeManager.class) permissionSchemeManager.getSchemes().each {GenericValue scheme -> if (ManagerFactory.getPermissionSchemeManager().getEntities(scheme, EDIT_ISSUE, "group", "administrators").isEmpty()) { log.debug("Modify scheme ${scheme.get('name')}".toString()) try { SchemeEntity schemeEntity = new SchemeEntity("group", "administrators", EDIT_ISSUE); permissionSchemeManager.createSchemeEntity(scheme, schemeEntity) } catch (Exception e) { log.warn ("Error updating scheme: ${scheme.get('name')}".toString()) } } else { log.debug("Scheme ${scheme.get('name')} already has an entry for this permission".toString()) } }
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.
you do have the java chops!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like this might not work in JIRA 7 anymore. Error No signature of method: static com.atlassian.jira.ManagerFactory.getPermissionSchemeManager() is applicable for argument types: () values: [] groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.ManagerFactory.getPermissionSchemeManager() is applicable for argument types: () values: [] at Script40$_run_closure1.doCall(Script40.groovy:16) at Script40.run(Script40.groovy:15)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can replace with ComponentAccessor.getPermissionSchemeManager().
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems like line 15 is complaining about not finding a matching method, but it still seems to put the group in the permission schemes. Note to anyone doing this that the permission helper is bugged per https://jira.atlassian.com/browse/JRA-45210 import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.permission.PermissionSchemeManager import com.atlassian.jira.scheme.SchemeEntity import org.apache.log4j.Level import org.apache.log4j.Logger import org.ofbiz.core.entity.GenericValue import static com.atlassian.jira.security.Permissions.BROWSE Logger log = Logger.getLogger("OneOffAddBrowsePermissionForSystemAdmins"); log.setLevel(Level.DEBUG) PermissionSchemeManager permissionSchemeManager = ComponentManager.getComponentInstanceOfType(PermissionSchemeManager.class) permissionSchemeManager.getSchemes().each {GenericValue scheme -> if (ComponentAccessor.getPermissionSchemeManager().getEntities(scheme, BROWSE, "group", "JIRA System Administrators").isEmpty()) { log.debug("Modify scheme ${scheme.get('name')}".toString()) try { SchemeEntity schemeEntity = new SchemeEntity("group", "JIRA System Administrators", BROWSE); permissionSchemeManager.createSchemeEntity(scheme, schemeEntity) } catch (Exception e) { log.warn ("Error updating scheme: ${scheme.get('name')}".toString()) } } else { log.debug("Scheme ${scheme.get('name')} already has an entry for this permission".toString()) } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
using "BROWSE as Long" will fix the type checking error, but it's not necessary. This script needs rewriting for the uptodate APIs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie's excellent example was for the Anyone group (null). For other groups, use this:
// parameter is the group name, type is "group", "projectrole" entities = permissionSchemeManager.getEntities(scheme, Permissions.BROWSE, "group", group_name);
To get more info use:
entities = permissionSchemeManager.getEntities(scheme, Permissions.BROWSE)
and print the entities out to get the correct value for type and parameter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a way to Bulk edit the name of the entities like Permission Scheme, Notification scheme, Issue type scheme etc automatiaclly using script ?
Thanks,
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should be able to use the Script Runner and a script to do that, similar to the ones above
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.