Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is there a way to assign a workgroup to many permission schemes without having to go into each one individuall?

JanaW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2013

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.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2013

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())
    }
}

Jason Smith November 24, 2014

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!

Jason Smith November 24, 2014

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()) } }

Jason Smith November 24, 2014

Don't forget to change the logger entry like I did. :)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 24, 2014

you do have the java chops!

Jason Smith January 12, 2016

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)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2016

You can replace with ComponentAccessor.getPermissionSchemeManager().

Jason Smith January 13, 2016

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()) } }

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2016

using "BROWSE as Long" will fix the type checking error, but it's not necessary. This script needs rewriting for the uptodate APIs.

1 vote
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2013

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

Global Tools October 3, 2013

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

MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2013

You should be able to use the Script Runner and a script to do that, similar to the ones above

TAGS
AUG Leaders

Atlassian Community Events