Exception when I try to trigger buildflow job from workflow job

1,124 views
Skip to first unread message

EK

unread,
Jan 21, 2016, 8:45:12 AM1/21/16
to Jenkins Users
Hi , 

    I am facing the following error , we recently moved to workflow and when we try to run\trigger old build flow jobs from workflow jobs we get exception:
Stacktrace of exception is as below , appreciate if anyone can help\advice on this and how we can overcome the issue ? 

Best Regards
EK

FATAL: Cannot cast object 'MyWorkFlowJobName #3' with class 'org.jenkinsci.plugins.workflow.job.WorkflowRun' to class 'hudson.model.AbstractBuild'
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'MyWorkFlowJobName #3' with class 'org.jenkinsci.plugins.workflow.job.WorkflowRun' to class 'hudson.model.AbstractBuild'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599) at com.cloudbees.plugins.flow.FlowDSL$_executeFlowScript_closure1.doCall(FlowDSL.groovy:55) at sun.reflect.GeneratedMethodAccessor1187.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903) at groovy.lang.Closure.call(Closure.java:415) at groovy.lang.Closure.call(Closure.java:428) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1379) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1351) at org.codehaus.groovy.runtime.DefaultGroovyMethods$each.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.DefaultGroovyMethods$each.call(Unknown Source) at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods.groovy:26) at sun.reflect.GeneratedMethodAccessor941.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:51) at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at com.cloudbees.plugins.flow.FlowDSL.executeFlowScript(FlowDSL.groovy:52) at com.cloudbees.plugins.flow.FlowRun$FlyweightTaskRunnerImpl.run(FlowRun.java:219) at hudson.model.Run.execute(Run.java:1738) at com.cloudbees.plugins.flow.FlowRun.run(FlowRun.java:155) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410)

EK

unread,
Jan 23, 2016, 3:22:04 AM1/23/16
to Jenkins Users
An example to reproduce :

this is my workflow script , it takes param1 (string) from user when running, and executes buildflowjob : 
#########
println(param1);
build job: 'buildflowjob', parameters: [[$class: 'StringParameterValue', name: 'param1', value:param1]]
#########

this is my buildflowjob script, it takes param1 (string) from user when running
########
println(params['param1']));
########

Craig Rodrigues

unread,
Jan 23, 2016, 3:49:12 PM1/23/16
to Jenkins Users, Eyask Kopty
Hi,

Thanks for posting your sample scripts.
I was able to reproduce your problem.

It looks like the Build Flow plugin needs to change to use the Run class, instead of AbstractBuild
in order to be compatible with workflow/pipeline plugin.

--
Craig


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/58cd91ef-7810-4c70-9d11-e162c386f5bb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Craig Rodrigues

unread,
Jan 23, 2016, 5:24:56 PM1/23/16
to Jenkins Users, Eyask Kopty
Hi,

I have a patch to address this issue.
Would you be willing to build the build-flow-plugin from my branch and provide feedback?
You can build it with:

git clone https://github.com/jenkinsci/build-flow-plugin
cd build-flow-plugin
git fetch origin pull/70/head:70
git checkout 70
mvn install

--
Craig

EK

unread,
Jan 24, 2016, 7:05:47 AM1/24/16
to Jenkins Users, eyas....@gmail.com, rod...@freebsd.org
Hi , 
I tired to follow your instruction to build the buildflow plugin and and got the following failures : 

Tests run: 45, Failures: 0, Errors: 45, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:57 min
[INFO] Finished at: 2016-01-24T13:37:31+02:00
[INFO] Final Memory: 56M/251M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.9:test (default-test) on project build-flow-plugin: There are test failures.
[ERROR]
[ERROR] Please refer to C:\GitTests\build-flow-plugin\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:

Craig Rodrigues

unread,
Jan 24, 2016, 3:56:59 PM1/24/16
to EK, Jenkins Users

Hi,

It looks like you are running under Windows.  I'm not sure if the tests run under Windows.
Try:

mvn -DskipTests install

--
Craig

On Jan 24, 2016 4:05 AM, "EK" <eyas....@gmail.com> wrote:
>
> Hi , 
> I tired to follow your instruction to build the buildflow plugin and and got the following failures : 
>

EK

unread,
Jan 24, 2016, 4:42:21 PM1/24/16
to Jenkins Users, eyas....@gmail.com, rod...@freebsd.org
Hi Craig, 

Looks like issue is solved and now can run build flow job from workflow job.
Many thanks for that as now I don't need to convert all my build flow jobs to workflow.

question : 
will this be an official fix to the build flow plugin? 

Best Regards




On Sunday, January 24, 2016 at 10:56:59 PM UTC+2, Craig Rodrigues wrote:

Hi,

It looks like you are running under Windows.  I'm not sure if the tests run under Windows.
Try:

mvn -DskipTests install

--
Craig

Craig Rodrigues

unread,
May 11, 2016, 9:19:51 PM5/11/16
to EK, Jenkins Users
Hi,

Sorry for the delay.  This fix is now in build-flow-plugin 0.19.  Please give it a try and provide feedback.

--
Craig

Reply all
Reply to author
Forward
0 new messages