I want to automate/set the Issue Security Level from with a groovy script (in a listener script, based on some other info in the issue).
Next code seems to work:
...
mutableIssue.setSecurityLevelId(issueSecurityLevelId)
issueManager.updateIssue(securityUser, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
...
where issueSecurityLevelId is the id of a Issue Security Level that is in a scheme associated with the project the issue is in. And securityUser is a user that has the rights in the project to set the Issue Security Level.
For my test I hard coded the Issue Security Level id.
But my question: how to find the issue Security Levels that can be used with the current project ? Or how to get the Issue Security Scheme associated with the project, and how to get the Issue Security Levels in the Scheme ?
Hi Marc,
Hopefully the following will help
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager
def issueSecuritySchemeManager = ComponentAccessor.getComponent(IssueSecuritySchemeManager)
def issueSecurityLevelManager = ComponentAccessor.getComponent(IssueSecurityLevelManager)
def schemeFromName = issueSecuritySchemeManager.getSchemeObjects().find { it.name == "Name of the Scheme" }
def schemeFromProject = issueSecuritySchemeManager.getSchemeFor(ComponentAccessor.projectManager.getProjectByCurrentKey("ATG"))
def securityLvl = issueSecurityLevelManager.getIssueSecurityLevels(schemeFromName.id).find { it ->
it.name == "Security Level A"
}?.id
Let me know if you have any more questions,
Regards, Thanos
Hi Thanos,
Thanks for your answer.I was missing the method issueSecuritySchemeManager.getSchemeFor(Project) !
This indeed solves my problem!
Marc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos,
I need to do the same thing here but in Scriptrunner Cloud version. I cannot find documentation on how to set "Issue Level Security" using a Listener in Scriptrunner Cloud.
Respectfully,
Aaorn
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.