Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28784

junit-attachments plugin not compatible with Pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The JUnit-attachments-plugin doesn appear to be compatible with Workflow jobs.

      Test for reproducing the issue:

      Create the following Workflow job:

      node ('master') {
        sh '''
           mkdir -p test
           cd test
           wget http://lazerbrody.typepad.com/photos/uncategorized/2007/03/22/mammy_yokum_broigges.jpg
           cat << EOF > test.xml
      <testsuites>
          <testsuite name="Customer Demographics Tests" tests="9" failures="0" timestamp="2012-08-23T14:40:44.874443-05:00">
              <testcase name="Insert First Name" classname="CustomerDemographicsPKG.Name"/>
              <testcase name="Insert Middle Name" classname="CustomerDemographicsPKG.Name">
                <system-out>[[ATTACHMENT|test/mammy_yokum_broigges.jpg]]</system-out>
              </testcase>
              <testcase name="Insert Last Name" classname="CustomerDemographicsPKG.Name">
                 <skipped>For no good reason!</skipped>
              </testcase>
          </testsuite>
      </testsuites>
      EOF
      '''
       // step([$class: 'JUnitResultArchiver', testResults: 'test/*.xml']) 
       step([$class: 'JUnitResultArchiver', testDataPublishers: [[$class: 'AttachmentPublisher']], testResults: 'test/*.xml'])
      }
      
      

      Observed result:

      Started by user thomas
      Running: Allocate node : Start
      Running on master in /var/lib/jenkins/workspace/WFJUnitPostBuild
      Running: Allocate node : Body : Start
      Running: Shell Script
      [WFJUnitPostBuild] Running shell script
      + mkdir -p test
      + cd test
      + wget http://lazerbrody.typepad.com/photos/uncategorized/2007/03/22/mammy_yokum_broigges.jpg
      --2015-06-07 13:07:51--  http://lazerbrody.typepad.com/photos/uncategorized/2007/03/22/mammy_yokum_broigges.jpg
      Resolving lazerbrody.typepad.com (lazerbrody.typepad.com)... 190.93.247.9, 141.101.115.9, 190.93.245.9, ...
      Connecting to lazerbrody.typepad.com (lazerbrody.typepad.com)|190.93.247.9|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 18510 (18K) [image/jpeg]
      Saving to: ‘mammy_yokum_broigges.jpg’
      
           0K .......... ........                                   100%  787K=0,02s
      
      2015-06-07 13:07:52 (787 KB/s) - ‘mammy_yokum_broigges.jpg.1’ saved [18510/18510]
      
      + cat
      Running: General Build Step
      Running: Allocate node : Body : End
      Running: Allocate node : End
      Running: End of Workflow
      java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to java.lang.Class
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:224)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.mapList(DescribableHelper.java:263)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:248)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:186)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.injectSetters(DescribableHelper.java:308)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:93)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:236)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:186)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:91)
      	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:103)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:133)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
      	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:105)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:75)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:60)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:103)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:100)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
      	at WorkflowScript.run(WorkflowScript:21)
      	at Unknown.Unknown(Unknown)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:69)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
      	at sun.reflect.GeneratedMethodAccessor477.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
      	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
      	at sun.reflect.GeneratedMethodAccessor534.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:145)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:106)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:271)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:71)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:180)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:178)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Finished: FAILURE
      

        Attachments

          Issue Links

            Activity

            Hide
            apemberton Andy Pemberton added a comment - - edited

            This problem appears to affect other testDataPublishers (perhaps all?), such as the SauceOnDemandReportPublisher.

            I believe the issue comes down to how the code in DescribableHelper.coerce handles the reflect. Specifically, the following line returns a WildCardTypeImpl:

            return mapList(context, ((ParameterizedType) type).getActualTypeArguments()[0], (List) o);
            

            Which is subsequently attempted to be cast to a Class, causing:

            java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to java.lang.Class 
            
            Show
            apemberton Andy Pemberton added a comment - - edited This problem appears to affect other testDataPublishers (perhaps all?), such as the SauceOnDemandReportPublisher. I believe the issue comes down to how the code in DescribableHelper.coerce handles the reflect. Specifically, the following line returns a WildCardTypeImpl: return mapList(context, ((ParameterizedType) type).getActualTypeArguments()[0], (List) o); Which is subsequently attempted to be cast to a Class, causing: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to java.lang. Class
            Hide
            jglick Jesse Glick added a comment -

            Possibly a duplicate of JENKINS-26535.

            However Andy also noted (apparently unfiled?) that the methods signatures inside junit-plugin refer to AbstractBuild and so would not work even if you construct the JUnitResultArchiver explicitly as a Java object.

            Show
            jglick Jesse Glick added a comment - Possibly a duplicate of JENKINS-26535 . However Andy also noted (apparently unfiled?) that the methods signatures inside junit-plugin refer to AbstractBuild and so would not work even if you construct the JUnitResultArchiver explicitly as a Java object.
            Hide
            abayer Andrew Bayer added a comment -

            Renamed the JIRA, assigned it to me - I don't know about the wildcard errors, but I do know the other compatibility errors, so I'll work on that.

            Show
            abayer Andrew Bayer added a comment - Renamed the JIRA, assigned it to me - I don't know about the wildcard errors, but I do know the other compatibility errors, so I'll work on that.
            Hide
            abayer Andrew Bayer added a comment -

            Fixed and released in JUnit plugin 1.14 and JUnit Attachments plugin 1.4.

            Show
            abayer Andrew Bayer added a comment - Fixed and released in JUnit plugin 1.14 and JUnit Attachments plugin 1.4.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                tg9541 Thomas Goeppel
              • Votes:
                3 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: