I had the problem some days ago with internal housekeeping system groovy
script. Until the workflow-plugin, virtually every build in a Jenkins
instance seems to be an AbstractBuild instance. So, I lazily assumed that
anything can be casted down to AbstractBuild when asking
Jenkins.getItems(). Basically the work inside the code (in a Jenkins
plugin) would certainly boil down to going a bit higher in the hierarchy
(I'd say, the highest possible with the method you try to call).

Here:
https://github.com/jenkinsci/zentimestamp-plugin/blob/master/src/main/java/hudson/plugins/zentimestamp/ZenTimestampEnvironmentContributor.java#L23


IMO, this is a bug to report to the plugin. And this is likely to be an
issue encountered more and more in the upcoming months as people starts
using the workflow plugin with many plugins combinations.

Cheers

2015-02-13 17:25 GMT+01:00 Jan-Olav Eide <[email protected]>:

> Trying the new workflow plugin, the following script
>
> node {
>   svn url: 'https://svnserver.intra.buypass.no/svn/bps/smoketests/trunk/'
>   def mvnHome = tool 'Maven-3.2.1'
>   bat "${mvnHome}\\bin\\mvn clean compile"
> }
>
> fails with
>
> Running: Allocate node : Start
> Running on master in C:\Jenkins\workspace\Demo workflow
> Running: Allocate node : Body : Start
> Running: Subversion
> Running: Allocate node : Body : End
> Running: Allocate node : End
> Running: End of Workflow
> java.lang.ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowRun 
> cannot be cast to hudson.model.AbstractBuild
>       at 
> hudson.plugins.zentimestamp.ZenTimestampEnvironmentContributor.buildEnvironmentFor(ZenTimestampEnvironmentContributor.java:23)
>       at hudson.model.Run.getEnvironment(Run.java:2224)
>       at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:827)
>       at 
> org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:106)
>       at 
> org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
>       at 
> org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:70)
>       at 
> org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:34)
>       at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:136)
>       at 
> org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
>       at 
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
>       at 
> com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
>       at WorkflowScript.run(WorkflowScript:2)
>       at Unknown.Unknown(Unknown)
>
>
> Looks like the ZenTimestamper gets in the way ? Uninstalling it is not an
> option.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/7854c0c5-3f5c-4729-bebc-c91ff95586e7%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/7854c0c5-3f5c-4729-bebc-c91ff95586e7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS58LDtursBx41EYP5uYXt%2BOYQnj67QhyEqQwd_2zP0bzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to