我正在尝试将现有的一组Jenkins作业转换为新的管道语法,我不明白如何转换后构建操作“发布TestNG结果”.管道语法页面没有帮助,因为未列出此特定操作,因此我尝试了以下语法: step([
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)
所以我的问题是:
>是否可以使用’step’语句触发任何类型的作业后操作?
>如果是,是否有经验法则可以找到类名和属性名?
在与问题相关的情况下,我运行Jenkins 2.8,所有管道插件都是最新的,并且可以找到完整的Jenkins文件on GitHub
目前,TestNG插件与Pipelines不兼容.见 JENKINS-27121