Hello,
I am using a script listener triggered by the issue_commented event in order to recopy comments to a linked issue.
I would like to restrict the use to some projects though and I noticed that the project filter of the event is only applying for the issue concerned by the event.
So now my idea would be to get the list of values entered in the project filter and use it in the script to check if the linked issue is in the project listed.
But I cannot find how to recover this list of values in the script. Could somebody help me with that ?
Thank you very much in advance.
hello, looks like this one will give you list of listeners:
import com.onresolve.scriptrunner.runner.util.OSPropertyPersister
import com.onresolve.scriptrunner.runner.ListenerManagerImpl
import com.onresolve.scriptrunner.runner.ListenerManager
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
def listenerManager = ScriptRunnerImpl.getPluginComponent(ListenerManager)
OSPropertyPersister.loadList(ListenerManagerImpl.CONFIG_LISTENERS)
where you can find them by id and get list of project keys
Thank you very much for your quick answer, could you please precise to me how I will get the list of project keys ?
OSPropertyPersister.projects ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
like this:
def listenerList = OSPropertyPersister.loadList(ListenerManagerImpl.CONFIG_LISTENERS)
def projects = listenerList.find {
it.id == "fb47asb6-7619-42a9-8ef3-a9ce66e2d842"
}.projects
where you can find id in a listener page edit url:
$baseUrl/plugins/servlet/scriptrunner/admin/listeners/edit/fb47asb6-7619-42a9-8ef3-a9ce66e2d842
if listener is for all projects, the list it returns will be empty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh I really wouldn't have found it myself.
I still get error message in edit mode for the line below as well as for another line where I iterate, but strangely it does work.
def projects = listenerList.find {
it.id == "fb47asb6-7619-42a9-8ef3-a9ce66e2d842"
}.projects
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, groovy does some static typechecking and because we are not defining stuff statically, but dynamically here, it's not sure methods we are calling are legit.
Something along those lines.
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.