Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can i restrict user group to create an issues in Jira by using validator?

Deleted user
June 8, 2018

Hi All,

In my Jira project, we have 3 issue types and we have 5 users groups ADMIN, USERS, READERS, ScrumMaster and DEVELOPER. I want to put complete restriction to DEVELOPER groups to create one issues type in our project i.e DEVELOPER is not able to create and view one issue type and rest two he is able to create and view.

I am using validator script in issue workflow to restrict them but with that script, no groups are able to create that issues which I want to restrict for a developer.

I am adding validator script also with this. Can somebody help me solve this problem?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.security.groups.GroupManager
import java.util.List
import com.atlassian.jira.ComponentManager


def groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class)
def currentUser = ComponentAccessor.JiraAuthenticationContext.getLoggedInUser()

GroupManager.isUserInGroup(currentUser,"JIR_ADMIN,JIR_SCRUM MASTER,JIR_USER,JIR_READER,JIR_ADMIN,JIR_SCRUM MASTER,JIR_USER,JIR_READER,JIR_ADMIN,JIR_SCRUM MASTER,JIR_USER,JIR_READER")

 

1 answer

0 votes
Alexey Matveev
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 Champions.
June 8, 2018

It should be like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.security.groups.GroupManager
import java.util.List
import com.atlassian.jira.ComponentManager


def groupManager = ComponentManager.getGroupManager()
def currentUser = ComponentAccessor.JiraAuthenticationContext.getLoggedInUser()

return groupManager.isUserInGroup(currentUser,"JIR_ADMIN") || groupManager.isUserInGroup(currentUser,"JIR_SCRUM ") || groupManager.isUserInGroup(currentUser,"JIR_SCRUM  MASTER") ... and so on for all groups.

Also you should name groups as they are name in Jira. It is case sensitive.

Deleted user
June 8, 2018

Hi @Alexey Matveev,

Thanks For your suggestion. Again I am facing the problem. None of the group users are able to create an issue in Jira.

Regards,

Shubhanshu

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events