带有插件 RobotPublisher 的 Jenkinsfile 导致 java.lang.NullPointerException
Jenkinsfile with Plugin RobotPublisher causes java.lang.NullPointerException
我安装了Jenkins Plugin(1.6.5版本)直接在Jenkins中发布Robot Framework的测试结果
机器人测试用例 运行 成功并创建了必要的文件。
但是如果我想将结果发布到 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.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.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
[...]
感谢您提供插件版本!
RobotPublisher 2.0.0 之前的版本似乎有一个错误,因为 otherFiles
参数(应该是可选的)是必需的,如果您省略它,则会出现此错误。
我会通过添加一个与您的任何实际文件都不匹配的 otherFiles
参数来解决这个问题,例如:
otherFiles : '*.no_such_file',
我安装了Jenkins Plugin(1.6.5版本)直接在Jenkins中发布Robot Framework的测试结果
机器人测试用例 运行 成功并创建了必要的文件。
但是如果我想将结果发布到 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.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.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
[...]
感谢您提供插件版本!
RobotPublisher 2.0.0 之前的版本似乎有一个错误,因为 otherFiles
参数(应该是可选的)是必需的,如果您省略它,则会出现此错误。
我会通过添加一个与您的任何实际文件都不匹配的 otherFiles
参数来解决这个问题,例如:
otherFiles : '*.no_such_file',