I am looking for a way to restrict the creation of one issue type (available across all projects) to members of only one Active Directory group.
From other threads, it looks like the best option may be to write a groovy script validator on the Create action that checks the user's group membership before creating the issue. Two questions:
1) Is there a way to hide the issue type from the dropdown so that users not in that one group can't even see it as an option?
2) If not and the workflow validator is the best mechanism, can you provide sample code for achieving this? I am just learning Java and Groovy, and this is the first script I would be writing. This is what I have so far (which runs successfully, but I'm not sure if it will achieve what I want. :) ):
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
groupManager.isUserInGroup(issue.reporter?.name, '<groupname>')
Thanks!
If you have ScriptRunner installed (I'm guessing you may since you mention scripting), you can user a Behaviour to limit what is shown in the Issue Type dropdown when creating an issue. Here's documentation on doing so for project (not AD) groups, but I tend to think it wouldn't be too hard to adapt it to reference AD groups. We use a variation on this approach, and it works nicely.
https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/restricting-issue-types.html
Hi,
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def currentUser = authenticationContext.getLoggedInUser()
def groupManager = ComponentAccessor.getGroupManager()
String groupName = "Your-group-name"
if (!groupManager.getUsersInGroup(groupName).contains(currentUser)) {
InvalidInputException userErrorMsg = new InvalidInputException()
userErrorMsg.addError("Users from your group are not allowed to use issue type.")
throw userErrorMsg
}
(you cannot use the reporter since the issue is not created yet).
Antoine
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.
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.