jenkinsci / groovy-events-listener-plugin

A Jenkins plugin, which executes groovy code when an event occurs.
https://plugins.jenkins.io/groovy-events-listener-plugin/
MIT License
36 stars 34 forks source link

Multiconfiguration Project Issue #31

Closed ghost closed 5 years ago

ghost commented 8 years ago

Hello,

There seems to be a problem when using a multiconfiguration project:

Steps to reproduce

How can we reproduce the issue

  1. Create a multiconfiguration project

    Expected behaviour

groovy code executed for all subjobs created by multiconfig

Actual behaviour

exception thrown when main job is finalized:

Caught unhandled exception! No such property: executable for class: hudson.model.OneOffExecutor groovy.lang.MissingPropertyException: No such property: executable for class: hudson.model.OneOffExecutor at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296) at script14749187746241897647584.run(script14749187746241897647584.groovy:15) at script14749187746241897647584$run.call(Unknown Source) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.runScript(GlobalEventsPlugin.groovy:305) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.this$3$runScript(GlobalEventsPlugin.groovy) at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:64) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.safeExecGroovyCode(GlobalEventsPlugin.groovy:270) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.this$3$safeExecGroovyCode(GlobalEventsPlugin.groovy) at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.safeExecGroovyCode(GlobalEventsPlugin.groovy) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.this$3$safeExecGroovyCode(GlobalEventsPlugin.groovy) at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:64) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:190) at org.jenkinsci.plugins.globalEventsPlugin.GlobalEventsPlugin$DescriptorImpl.processEvent(GlobalEventsPlugin.groovy:219) at org.jenkinsci.plugins.globalEventsPlugin.GlobalRunListener.onFinalized(GlobalRunListener.java:54) at hudson.model.listeners.RunListener.fireFinalized(RunListener.java:233) at hudson.model.Run.onEndBuilding(Run.java:1891) at hudson.model.Run.execute(Run.java:1810) at hudson.matrix.MatrixBuild.run(MatrixBuild.java:301) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410)

Jimilian commented 7 years ago
Caught unhandled exception! No such property: executable for class: hudson.model.OneOffExecutor
groovy.lang.MissingPropertyException: No such property: executable for class: hudson.model.OneOffExecutor

It means that your groovy code are trying to access some property that was not provided by "Jenkins". You can avoid this issue by introducing custom checks (something like that, just to show idea):

if (run is instance of MultiConfigurationJob)
   continue
else
   doSomeMagic()

Also it would be nice to see minimal code to reproduce this bug.