jenkinsci / coordinator-plugin

Make deployment done by a single click.
https://plugins.jenkins.io/coordinator/
Other
16 stars 10 forks source link

Fails when using jenkins built in pipeline jobs #48

Open mchave opened 7 years ago

mchave commented 7 years ago

Repro:

Create 2 pipeline jobs (using Jenkins built in pipelines) and the try to run them.

Error:

Mar 28, 2017 2:50:27 PM WARNING org.eclipse.jetty.util.log.JavaUtilLog warn Error while serving http://xxxxxx/job/P14/job/TCU/job/Coordinator/2/pollActiveAtomicBuildsTableRowHtml java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:335) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:175) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:108) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:362) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:236) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:236) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:236) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) at org.kohsuke.stapler.Stapler.service(Stapler.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:86) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84) at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowJob cannot be cast to hudson.model.AbstractProject at org.jenkinsci.plugins.coordinator.model.CoordinatorBuild.retrieveTargetBuild(CoordinatorBuild.java:267) at org.jenkinsci.plugins.coordinator.model.CoordinatorBuild.prepareAtomicBuildInfo(CoordinatorBuild.java:248) at org.jenkinsci.plugins.coordinator.model.CoordinatorBuild.doPollActiveAtomicBuildsTableRowHtml(CoordinatorBuild.java:180) ... 79 more

ace-han commented 7 years ago

@mchave Could you provide how you configure/trigger the pipeline job?

The information you provided is not enough for us to locate the problem, thx.

philmadden83 commented 7 years ago

@mchave could you also provide the version of Jenkins are you running?

Max-Serra commented 7 years ago

Hi all,

What a concidence...I was just working with the plug in mentioned above in conjunction with Coordinator facing the same problem, that I have seen this thread discussion.

The pipeline plug-in, which is indeed a set of plug-ins, is included by default starting from jenkins 2.x. I found the issue just creating a simple pipeline job in jenkins 2.7.4, raising the following exception:

WARNING: Error while serving https:/XXXXXXXXXXXXXXXXXXX/view/Jobs_OS_Independent/job/Pipeline_Jobs_CLauncher/3/pollActiveAtomicBuildsTableRowHtml java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor286.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:324) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:167) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:100) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$11.dispatch(MetaClass.java:380) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:233) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:233) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) at org.kohsuke.stapler.Stapler.service(Stapler.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135) at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:225) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132) at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132) at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:58) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132) at jenkins.metrics.impl.MetricsFilter.doFilter(MetricsFilter.java:125) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84) at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowJob cannot be cast to hudson.model.AbstractProject at org.jenkinsci.plugins.coordinator.model.CoordinatorBuild.retrieveTargetBuild(CoordinatorBuild.java:261) at org.jenkinsci.plugins.coordinator.model.CoordinatorBuild.prepareAtomicBuildInfo(CoordinatorBuild.java:247) at org.jenkinsci.plugins.coordinator.model.CoordinatorBuild.doPollActiveAtomicBuildsTableRowHtml(CoordinatorBuild.java:180) ... 82 more

In the Configuration Section of the Coordinator Job, it's possible to add a pipeline job in the tree, but while running the Execution Plan it hangs forever and the icons leafs got corrupted.

Pipeline plug-in it's really widespread and flexible. I guess that in conjunction to Coordinator it's really powerful as well.

mchave commented 7 years ago

@philmadden83 we're running Jenkins ver. 2.32.3

@ace-han They're configured as pipeline jobs (formerly called workflows) which are running gradle and artifactory from SVN. Just triggering them manually at the moment in the coordinator, though the jobs themselves would trigger if there was a change in the source SVNs.

Thanks for your support. It looks to be great plugin, hopefully we can use it with pipeline jobs.

Max-Serra commented 7 years ago

Just further details. The exception trace above is related to the build execution time, not while adding such pipeline (but classified as Workflow) job in the Configuration phase. The trial Coordinator job I created was without any parameter, in fact just to check if it was able to work and to trigger that type of jobs (previously used Coordinator only with Freestyle Jobs).

Cheers

philmadden83 commented 7 years ago

I've take a look into this. The initial problem is that the WorkflowJob class is not a type of AbstratProject. I have altered the codebase to work with the common interfaces of AbstractProject and WorkflowJob.

However. There also seems to be a further problem where by cglib cannot generate a class of type WorkflowJob as the class is marked final (https://github.com/jenkinsci/workflow-job-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java#L109).

I'll create a fork of the workflow plugin and remove the final modifier. Hopefully they will accept.

ace-han commented 7 years ago

@mchave Have you tried out @philmadden83 's branch? I will merge it if the branch is working for your case Sorry for being late to respond to this thread.😅

Max-Serra commented 7 years ago

Hi @ace-han and @philmadden83,

In order to check if the fix is working, is it only needed to checkout the related branch for Coordinator project or is it required as well to update anything at the WorkflowJob/Pipeline side?

ace-han commented 7 years ago

@Max-Serra I think the fix should fix the issue as it described Fails when using jenkins built in pipeline jobs. So, it should at least get along with pipeline (It's okay to be triggered by pipeline job)

Max-Serra commented 7 years ago

@ace-han My question was due to the philmadden83's comment "I'll create a fork of the workflow plugin and remove the final modifier. Hopefully they will accept.". By your comment it seems that workaround was no longer needed, so the fix is applied only to Coordinator code...right?

ace-han commented 7 years ago

@philmadden83 Okay, I've got your intention. It's not always a good pattern to expect or force other plugin making changes to get around our problem. However, if they accept your pull request(PR) then every one is happy 😃
(btw, is the PR still not made? 'cuz I can't find it)

@Max-Serra @mchave I think that pipeline type jobs being configured within coordinator-plugin is unnecessary. Because, by definition of coordinator-plugin is to control other jobs to be built. And somehow pipeline is sort of doing the same. So, I would suggest pure coordinator-plugin or pure pipeline in the case that @philmadden83 's PR fails to be accepted.

Max-Serra commented 7 years ago

@ace-han It's true that pipeline plug-in can trigger even jobs, but the big difference against Coordinator is the approach and the usage. Coordinator can allow the creation of Execution plans by non Jenkins experts and especially non programmers and this is its peculiarity. Pipeline requires much more expertise to be used and in particular since a plan can be designed programmatically, to enable/disable jobs requires to modify a groovy script. So using Pipeline to manage jobs it's only a bit more flexible (but much more complicated) than using standard up/downstream approach and useful if the plan doesn't change each run (i.e. automatic trigger). The two plugins aren't interchangeable. On the other side athomic jobs configured by pipeline allows to solve many limitations due to old standard Freestyle jobs which provide only GUI configuration features and requires often installation of many plug-ins with possible unexpected bugs. I understand as well the maintenance complexity of Coordinator which must be aligned to non standard Parameters Plug-ins and different kind of Job plug-ins. Anyway it shouldn't be underestimated that Pipeline/Workflow plug-in is now distributed and integrated in standard Jenkins distributions. They aren't custom plug-ins.

Max-Serra commented 7 years ago

@philmadden83 Hi again. Is the only modification needed on WorkflowJob class, the removal of the final access modifier? If the answer is yes, we could fetch the source code from the related Github repo and build a snapshot version to try out the fix.

philmadden83 commented 7 years ago

Yes. I believe that to be the outstanding issue here.

@ace-han I'm holding off of the PR for now in case I think of an alternative approach. I would like to remove the need for CGLib altogether and solve the problem that way.

ace-han commented 7 years ago

Hi, @philmadden83 How is the alternative approach going? Anything I could help with?

humaruis commented 6 years ago

Hi @ace-han & @philmadden83 Any update on this?