How can I add class with script runner listener

fjodors
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 22, 2016

Hello

I created my own script runner listener that updates some custom fields from worklog.

I have to add this listener as groovy class, since I have to put this listener in 6.2.5 version of JIRA (I didn't find inline script in 6.2.5 version).

 

How can I do it?

My file name is "updatefromworklog.groovy"

I created directory with name "custom" in /opt/atlassian/jira/atlassian-jira/WEB-INF/classes/com and placed my file into it.

When I typing "com.custom.updatefromworklog.groovy" in "script file", there is error:

com.custom.updatefromworklog.groovy:1 Cannot find file: com.custom.updatefromworklog.groovy @ line 1, column 1.

 

Here is my class code

package updatefromworklog;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.manager.OptionsManager
class updatefromworklog extends AbstractIssueEventListener {
        Category log = Category.getInstance(ExampleListener.class)
        @Override
        void workflowEvent(IssueEvent event) {
                    def customFieldManager = ComponentAccessor.getCustomFieldManager()
                    def componentManager = ComponentManager.getInstance()
                    IssueManager issueManager = ComponentAccessor.getIssueManager();
                    //get issue
                    MutableIssue issueToUpdate = (MutableIssue) event.issue;
                    
                    // some code
        
        } //end void
} // end class

 

P.S. I trying to do it on 7.0.10 version of Jira, but I have to copy such listener in 6.2.5 version later.

 

 

Thank you in advance,

Fyodor

 

 

1 answer

1 accepted

0 votes
Answer accepted
JamieA
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 22, 2016

You cannot do it in both 7.0.10 and 6.2.5. If you are targeting 6.2.5 use that version.

Your package name needs to match your directory name, not sure if that is a typo.

The class needs to be under a script root, rather than WEB-INF/classes. Also check the old documentation, for your old version: https://jamieechlin.atlassian.net/wiki/display/GRV/Listeners.


fjodors
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 24, 2016

Hello Jamie

Thank you, now it works

mahesh.gautam July 1, 2016

I am running into a similar Issue. What do you mean by "The class needs to be under a script root"? Any help will be appreciated

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.
August 23, 2016

Mahesh,

There is a section in the documentation about the script roots

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events