Listener doesn't fire the script when it's configured in scriptrunner.yaml file

KAMIL RADEK February 12, 2018

I'm completely new in JIRA, please be patient :)

I've prepared custom Listener

package com.onresolve.scriptrunner.canned.jira.workflow

import com.onresolve.scriptrunner.canned.CannedScript
import com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener
import com.onresolve.scriptrunner.runner.ScriptRunner
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.ScriptListener
import groovy.util.logging.Log4j

@ScriptListener
@Log4j
class SampleScriptListener extends CustomListener implements CannedScript {
ScriptRunner scriptRunner = ScriptRunnerImpl.getScriptRunner()

@Override
String getName() {
    "Sample  custom listener"
}

@Override
String getDescription() {
    "Sample listener from a plugin"
}


@Override
Map doScript(Map<String, Object> params) {
    log.warn("ScriptRunner listener: do something here")    scriptRunner.runScript("com/example/SampleScript.groovy")
    return params
}

@Override
String getDescription(Map<String, String> params, boolean forPreview) {
    "preview description xxx"
}
}

and set it properties in scriptrunner.yaml file

!descriptor# jira listenersscriptListeners:
- FIELD_LISTENER_NOTES: A sample listener
  FIELD_MY_PARAM: my custom param
  canned-script: com.onresolve.scriptrunner.canned.jira.workflow.SampleScriptListener  events:
  - 1
  - 2
  - 3
  - 4
  - 5
  - 6
  - 10
  - 11
  - 12
  - 14
  - 15
  - 18
  - com.atlassian.crowd.event.user.UserCreatedEvent  projects:
  - 'testp'

Custom groovy script looks like this.

package com.example
log.warn "log from custom script"
return "return from custom script"

When I created script listener manually (in the GUI) it worked fine. It was possible to edit parameters and after declared action (assign) script logged in to the console. problem is that ScriptListener created in scriptrunner.yaml is inactive and I can't edit it parameters.
My question is where can I find documentation for this functionality or how to prepare scriptrunner.yaml.

1 answer

0 votes
Jenna Davis
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.
February 12, 2018

Hello, 

You can find information on generating the scriptrunner.yaml file here. You might want to just take a look at the entire Creating a Script Plugin page from the documentation, it contains quite a bit of useful information that should help you get started. 

Please let me know if you have any further questions!

Jenna

KAMIL RADEK February 13, 2018

Hi.

Thank you for the answer.
It's makes more sense to generate scriptrunner.yaml than writing it :)
Informations from "Creating a Script Plugin" article give us possibility to get new data from property file by running "mvn package". Is there another way to perform the same task from GUI perspective?

Jenna Davis
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.
February 14, 2018

I don't believe there is at the moment. You'll have to do that manually. 

KAMIL RADEK February 16, 2018

Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events