2016-06-09 68 views
4

我試圖將一組現有的Jenkins作業轉換爲新的管道語法,並且我不知道如何轉換後期製作操作「發佈TestNG結果」。管道語法頁面不利於爲未列出此特定的動作,所以我試過的語法如下:在Jenkinsfile中執行「發佈TestNG結果」步驟

step([$class: 'hudson.plugins.testng.Publisher', reportFilenamePattern: 'test-output/testng-results.xml']) 

我的假設是類名必須config.xml中的內容相匹配當前配置:

<hudson.plugins.testng.Publisher plugin="[email protected]"> 
    <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'語句觸發任何類型的工作後操作?
  • 如果是,是否有一條經驗法則來查找類名和屬性名?

如果這是相關的問題,我運行詹金斯2.8所有管道插件更新,並全面Jenkinsfile可以發現on GitHub

回答

2

此時,TestNG插件不與管道兼容。請參閱JENKINS-27121

5

發佈TestNG測試結果現在可用於管道。 用途:

step([$class: 'Publisher']) 

或結果文件的自定義位置:

step([$class: 'Publisher', reportFilenamePattern: '**/custom/testng-results.xml']) 

根據this comment on Jenkins Jira增加管道片斷髮電機正在等待。

(在Jenkins 2.9.13和Pipeline插件2.4上測試)

+0

我還必須將TestNG插件更新到1.14 – checketts