I'm attempting to create a custom listener using Script Runner, but I can't quite figure out how to get it configured. I hope if I clearly outline what I thought was the correct steps were to configure the custom listener, someone will find where I'm going wrong. My money is that it's something incredibly simple that goes to show my lack of programming experience. ;)
class TaskVersionListener extends AbstractIssueEventListener { Category log = Category.getInstance(TaskVersionListener.class) @Override void workflowEvent(IssueEvent event) { log.debug "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by TaskVersionListener" } }
When doing so, i get the following error:
Not Found (404)
Could not execute action [CannedScriptListener]:Incompatible magic value 1668047219 in class file com/custom/TaskVersionListener<p><small><small><pre>java.lang.ClassFormatError: Incompatible magic value 1668047219 in class file com/custom/TaskVersionListener at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at
it seems a restart of the JIRA service did the trick. i'm not sure we'll ever know what was causing the misbehavior.
Do you have a
package com.custom
in your script?
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
good catch. i realized that was missing yesterday as well, added it, ran the same steps you see above, but .. alas .. i continue to get the same error that i posted above. any other ideas, henning?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mmh.. I tried this script in our instance and get the corresponding log messages:
package com.custom import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import org.apache.log4j.Category class TaskVersionListener extends AbstractIssueEventListener { Category log = Category.getInstance(TaskVersionListener.class) @Override void workflowEvent(IssueEvent event) { log.setLevel(org.apache.log4j.Level.DEBUG) log.debug "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by TaskVersionListener" } }
If this is like your script, than I have no idea. It's exactly like I did it with my listeners...
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hrm yeah... I think you're mixing up the old and the new way of setting up custom script listeners. Been a while since I've looked at this myself but...
You don't need the Admin -> Listeners one you set up... although that method will probably work. But if you use that you need to click Edit and specify the path to the groovy file.
I've not seen that error about the magic file, it's like it's finding a a .groovy file when it expects a compiled class.
What version of the plugin and what of jira?
I'll go through this myself tomorrow and make sure the docs are up to date.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, Jamie. Love the plugin and your work and thanks for the reply. To your answer:
I'll keep an eye out for any further instructions. Thanks for the help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
jamie, i still haven't been able to identify what's going wrong for me here. any advice?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tanner,
I have created two questions:
https://answers.atlassian.com/questions/223228/groovy-custom-listener-to-update-components-field
Thanks for getting back.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
package com.custom import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.project.Project import com.atlassian.jira.issue.customfields.option.Option; import com.atlassian.jira.bc.project.component.ProjectComponent import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.MutableIssue import com.atlassian.crowd.embedded.api.User import com.atlassian.event.api.EventListener import com.atlassian.jira.util.ImportUtils import org.apache.log4j.Category class UpdateFieldComponent extends AbstractIssueEventListener { Category log = Category.getInstance(UpdateFieldComponent.class) UpdateFieldComponent () { log.setLevel(org.apache.log4j.Level.DEBUG) } @EventListener void workflowUpdated(IssueEvent event) { log.debug "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by UpdateFieldComponent" CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager(); def cf=cfm.getCustomFieldObjectByName("Type of Request") Option cfValue=(Option)issue.getCustomFieldValue(cf); if (cfValue.getValue().equals("G1 Block")) { Project project = issue.getProjectObject() ProjectComponent component = ComponentAccessor.getProjectComponentManager().findByComponentName(project.getId(), "G1 Block") issue.setComponentObjects([component]) } else { Project project = issue.getProjectObject() ProjectComponent component = ComponentAccessor.getProjectComponentManager().findByComponentName(project.getId(), "1 - Inbox") issue.setComponentObjects([component]) } } }
Hi,
I have added my listener to script runner, but it doesnt seem to do what I want it to. I.e update the components field when a custom field value is selected and Issue Updated event has been fired. Any ideas? Do I need to restart JIRA?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you'll probably get a better response if you open up another question. i think i know your answer, but i'll first wait for that new question before i answer. be sure to comment here with a link to it, and i'll reply.
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.