Answer a question

I installed the Jenkins Plugin (version 1.6.5) to publish test results of Robot Framework directly in Jenkins.
The robot test cases ran successfully and created necessary files.
But if I want to publish the results to Jenkins, the pipeline throws an exception.

Jenkinsfile

pipeline {
  agent any
  stages {
    stage("Run Robot") {
      steps {
        sh "robot --outputdir robot-results robot-test-cases"
        script {
          step([$class : 'RobotPublisher',
                outputPath : 'robot-results',
                outputFileName : "**/output.xml",
                reportFileName : '**/report.html',
                logFileName    : '**/log.html',
                disableArchiveOutput : false,
                passThreshold: 100.0,
                unstableThreshold: 90.0])
        }
      }
    }
  }
}

Pipeline log with the exception

[...]
Output: robot-results/output.xml
Log: robot-results/log.html
Report: robot-results/report.html

[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.NullPointerException
         at hudson.plugins.robot.RobotPublisher.<init>(RobotPublisher.java:106)
Caused: java.lang.reflect.InvocationTargetException 
        at sun.reflect.GeneratedConstructorAccessor584.newInstance(Unknown Source)  
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
        at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:330)
Caused: java.lang.IllegalArgumentException: Could not instantiate {outputFileName=**/output.xml, reportFileName=**/report.html, outputPath=robot-results, logFileName=**/log.html, unstableThreshold=90.0, passThreshold=100.0, disableArchiveOutput=false} for hudson.plugins.robot.RobotPublisher 
       at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334) 
       at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:474)   
       at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)   
       at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329) 
       at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:272) 
       at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:205)  at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:264)  
       at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:178) 
       at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122) 
       at sun.reflect.GeneratedMethodAccessor270.invoke(Unknown Source) 
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
       at java.lang.reflect.Method.invoke(Method.java:498)   
       at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)  
       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)    
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)   
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)   
       at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)    
       at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
       at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:160)  
       at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)  
       at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)  at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158) 
       at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:162) 
       at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132) 
       at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
Caused: java.lang.IllegalArgumentException: Could not instantiate {delegate={$class=RobotPublisher, outputPath=robot-results, outputFileName=**/output.xml, reportFileName=**/report.html, logFileName=**/log.html, disableArchiveOutput=false, passThreshold=100.0, unstableThreshold=90.0}} for org.jenkinsci.plugins.workflow.steps.CoreStep
  [...]

Answers

Thank you for including the version of the plugin!

It appears that RobotPublisher prior to version 2.0.0 had a bug in that the otherFiles parameter (which should be optional) was required, and if you omit it you get this error.

I would address this by adding an otherFiles parameter that doesn't match any of your actual files, for example:

        otherFiles : '*.no_such_file',
Logo

CI/CD社区为您提供最前沿的新闻资讯和知识内容

更多推荐