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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,607
Community Members
 
Community Events
185
Community Groups

Scriptrunner and Issue Security Levels

Edited
Marc Minten _EVS_
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 Leaders.
Feb 20, 2018

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 ?

1 answer

1 accepted

2 votes
Answer accepted
Thanos Batagiannis [Adaptavist]
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 Leaders.
Feb 26, 2018 • edited

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

Marc Minten _EVS_
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 Leaders.
Feb 26, 2018

Hi Thanos,

Thanks for your answer.I was missing the method issueSecuritySchemeManager.getSchemeFor(Project) !

This indeed solves my problem!

Marc

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events