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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Assign permission scheme to all Projects in a Project Category (Code/Scriptrunner) Edited

Hello, 

I know how to assign a permission scheme of a Template Project to another Project:

 

import org.springframework.stereotype.Component;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.workflow.AssignableWorkflowScheme;
import com.atlassian.jira.workflow.DraftWorkflowScheme;
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.jira.workflow.WorkflowScheme;
import com.atlassian.jira.workflow.WorkflowSchemeManager;

def projectDefault = ComponentAccessor.getProjectManager().getProjectObjByKey("DPDefault");
def projectNeu = ComponentAccessor.getProjectManager().getProjectObjByKey("DPNeu");
ComponentAccessor.getWorkflowSchemeManager().removeSchemesFromProject(projectNeu);
ComponentAccessor.getWorkflowSchemeManager().addSchemeToProject(projectNeu, ComponentAccessor.getWorkflowSchemeManager().getSchemeFor(projectDefault));

But how do I do this to every single project of a project category? Or do I really need to change the permission scheme for each project in it? Thanks! 

1 answer

1 accepted

0 votes
Answer accepted
Leo Community Leader Nov 06, 2020

Hi @Sngy ,

Below code snippet may give you some idea, I didn't test this in my server though

import com.atlassian.jira.component.ComponentAccessor
def prcat = ComponentAccessor.getProjectManager().getProjectCategoryObjectByName("Code/Scriptrunner")
def prList = ComponentAccessor.getProjectManager().getProjectsFromProjectCategory(prcat)

prList.each{ proj ->
//code here
}

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you