带有插件 RobotPublisher 的 Jenkinsfile 导致 java.lang.NullPointerException

问题描述 投票:0回答:2

我安装了Jenkins Plugin(版本1.6.5),直接在Jenkins中发布Robot Framework的测试结果。
机器人测试用例成功运行并创建了必要的文件。
但如果我想将结果发布到 Jenkins,管道会抛出异常。

Jenkins文件

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])
        }
      }
    }
  }
}

管道日志有异常

[...]
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
  [...]
java jenkins nullpointerexception jenkins-pipeline robotframework
2个回答
1
投票

感谢您提供插件的版本!

RobotPublisher 2.0.0 之前的版本似乎有一个错误,即需要

otherFiles
参数(应该是可选的),如果省略它,则会收到此错误。

我将通过添加与任何实际文件都不匹配的

otherFiles
参数来解决此问题,例如:

        otherFiles : '*.no_such_file',

0
投票

有时,当插件不支持机器人框架版本时,可能会发生这种情况。

Pip 安装了最新的 RF,因此我得到了 RF7。但是 jenkins 插件还没有配备来处理它,所以得到了相同的

java.lang.NullPointerException
错误。

参考问题:

https://github.com/robotframework/robotframework/issues/5018

https://github.com/jenkinsci/robot-plugin/pull/64

© www.soinside.com 2019 - 2024. All rights reserved.