我正在尝试将现有的一组Jenkins作业转换为新的管道语法,我不明白如何转换后构建操作“发布TestNG结果”。管道语法页面没有帮助,因为未列出此特定操作,因此我尝试了以下语法:
step([$class: 'hudson.plugins.testng.Publisher', reportFilenamePattern: 'test-output/testng-results.xml'])
我的假设是类名必须与当前配置中config.xml的内容相匹配:
<hudson.plugins.testng.Publisher plugin="testng-plugin@1.10">
<reportFilenamePattern>test-output/testng-results.xml</reportFilenamePattern>
<escapeTestDescp>true</escapeTestDescp>
<escapeExceptionMsg>true</escapeExceptionMsg>
<showFailedBuilds>false</showFailedBuilds>
<unstableOnSkippedTests>false</unstableOnSkippedTests>
<failureOnFailedTestConfig>false</failureOnFailedTestConfig>
</hudson.plugins.testng.Publisher>
但是,执行语句时会抛出异常:
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:193)
at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:104)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:134)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113)
at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
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:151)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
at WorkflowScript.testBranch(WorkflowScript:71)
所以我的问题是:
如果与问题相关,我正在运行Jenkins 2.8,所有管道插件都是最新的,并且可以找到完整的Jenkins文件on GitHub
答案 0 :(得分:13)
发布TestNG测试结果现在可以在管道中使用。 使用:
step([$class: 'Publisher'])
或结果文件的自定义位置:
step([$class: 'Publisher', reportFilenamePattern: '**/custom/testng-results.xml'])
根据this comment on Jenkins Jira添加到Pipeline代码段生成器正在等待。
(在Jenkins 2.9.13和Pipeline插件2.4上测试)
答案 1 :(得分:2)
目前,TestNG插件与Pipelines不兼容。见JENKINS-27121