Hi,
I need to add around 300 'Security Levels' to a particular 'Issue Security Scheme' in JIRA along with the groups.
Is it possible to implement this using Scriptrunner plugin or through Groovy or any other way?
Thanks,
Rupa
Here is code to create a new scheme, and a new level with a single group:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.security.IssueSecuritySchemeManager import com.atlassian.jira.scheme.SchemeEntity def issueSecurityLevelManager = ComponentAccessor.getIssueSecurityLevelManager() def issueSecuritySchemeManager = ComponentAccessor.getComponent(IssueSecuritySchemeManager) def scheme = issueSecuritySchemeManager.createSchemeObject("FRIDAY", "Issue security scheme for testing") def level = issueSecurityLevelManager.createIssueSecurityLevel(scheme.id, "Private", "Group only") def entity = new SchemeEntity("group", "jira-users", level.id) def gv = issueSecuritySchemeManager.getScheme(scheme.id) issueSecuritySchemeManager.createSchemeEntity(gv, entity)
woah! 300 security levels on a single scheme? Don't you want to re-think the architecture?
issueSecurityLevelManager.createIssueSecurityLevel(scheme.id, "Private", "Reporter only")
But, agree with Alex.
Jamie,
I tried the following:
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
IssueSecurityLevelManager issueSecurityLevelManager;issueSecurityLevelManager.createIssueSecurityLevel(11238,"Sample Level","Example")
But getting an error : Cannot invoke method createIssueSecurityLevel() on null object
Also is there a way to add group-name or multiple group-names to Security levels?
We have that many different customers using the same project and hence need that many levels so that they cannot see tickets created by other Customers.
I will propose the solution I have implemented in my company in the answer section, cause select one of 300 security levels from the dropdown will be a headache.
May I propose a better solution? I have implemented something like this in my company see the link: "Visible For" field in JIRA
Now, if you need the issue to be visible by that customer, just add him to Visible For
P.S. Add all customers to any project role with browse permission, so that role can see issues in the project - permission scheme.
The Security Level is set automatically through Groovy post function depending on which group the Reporter belongs to.
Example: Say there are two Customers ABC and XYZ. ABC has 2 users Sam and Betty.XYZ has 2 users Tom and Harry.
What we need is that Sam can see what ticket Betty creates (what users of ABC create) and should not be able to view what all tickets Tom and Harry create(XYZ users).
Is this possible using your solution?
Issue security levels can have a "Group Custom Field Value". Why don't you write the customer group to a group custom field (can be hidden), and use that in the security scheme.
it's ok if you don't need single user view only... I have proposed the solution with custom field multiple users, the same approach
Your method is very flexible, I agree. Easy to combine multiple groups etc if you need to.
I had previously used Jelly to accomplish this:
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib"><jira:CreateIssueSecurityScheme name="FRIDAY ISSUE SCHEME"><jira:AddIssueSecurityLevel name="Test level1" description=""><jira:AddIssueSecurity type="group" group="abc-users"/><jira:AddIssueSecurity type="group" group="xyz-users"/></jira:AddIssueSecurityLevel></jira:CreateIssueSecurityScheme></JiraJelly>
Looking to find its alternative within Scriptrunner.
You can change multiple user picker to multiple group picker and put Sam's group in that field. (you can even make a postfunction to fill visible for field with sam's group)
You have to get the IssueSecurityLevelManager via ComponentAccessor
def issueSecurityLevelManager = ComponentAccessor.getIssueSecurityLevelManager()
Is it possible to make this Group Picker field non-searchable when using Advanced JQL?
I tried using the 'Search Template' but it does not work.
I'm trying to get this to work in Jira 7.3.1, can you help? The final two lines no longer work it seems
https://community.atlassian.com/t5/JIRA-questions/Add-group-to-security-level-Groovy/qaq-p/616979#M204150
Worked with JIRA 7.1.9
Hi!
Need help with creating the the entity for user custom field value (multiuser customfield) , I tried
It looks like you're new here. Sign in or register to get started.