Jenkins JUnit返回null

Jenkins JUnit返回null,junit,jenkins-groovy,Junit,Jenkins Groovy,在我的脚本管道中,我调用junit如下 Recording test results null <testsuites> <testsuite errors="1" failures="0" tests="1" time="0"> <testcase name="workspace/inventory/group1"> <fail

在我的脚本管道中,我调用junit如下

Recording test results
null
<testsuites>
  <testsuite errors="1" failures="0" tests="1" time="0">
    <testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
    </testcase>
  </testsuite>
</testsuites>`

<testcase name="workspace/inventory/group1.yml">
      <failure file="workspace/inventory/group1.yml" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
<testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>

junit“${log\u dir}/${os\u version}/*.xml”

然而,它给出的结果如下

Recording test results
null
<testsuites>
  <testsuite errors="1" failures="0" tests="1" time="0">
    <testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
    </testcase>
  </testsuite>
</testsuites>`

<testcase name="workspace/inventory/group1.yml">
      <failure file="workspace/inventory/group1.yml" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
<testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>

然后是一堆空异常

at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
        at hudson.remoting.Channel.call(Channel.java:998)
        at hudson.FilePath.act(FilePath.java:1069)
        at hudson.FilePath.act(FilePath.java:1058)
        at hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:107)
        at hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:149)
        at hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:243)
        at hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:63)
        at hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:29)
        at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.lang.NullPointerException
    at hudson.tasks.junit.CaseResult.getPackageName(CaseResult.java:399)
    at hudson.tasks.junit.TestResult.tally(TestResult.java:795)
    at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:145)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3073)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:369)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
我的xml文件如下所示

Recording test results
null
<testsuites>
  <testsuite errors="1" failures="0" tests="1" time="0">
    <testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
    </testcase>
  </testsuite>
</testsuites>`

<testcase name="workspace/inventory/group1.yml">
      <failure file="workspace/inventory/group1.yml" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
<testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>


[E201]尾随空格
`

通过向正在删除的文件名添加.yml扩展名进行修复。所以现在
标记行如下所示

Recording test results
null
<testsuites>
  <testsuite errors="1" failures="0" tests="1" time="0">
    <testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
    </testcase>
  </testsuite>
</testsuites>`

<testcase name="workspace/inventory/group1.yml">
      <failure file="workspace/inventory/group1.yml" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
<testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>


[E201]尾随空格
现在junit能够正确地解析

PS:前面的条目如下

Recording test results
null
<testsuites>
  <testsuite errors="1" failures="0" tests="1" time="0">
    <testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
    </testcase>
  </testsuite>
</testsuites>`

<testcase name="workspace/inventory/group1.yml">
      <failure file="workspace/inventory/group1.yml" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>
<testcase name="workspace/inventory/group1">
      <failure file="workspace/inventory/group1" line="94" message="[E201] Trailing whitespace" type="Ansible Lint">[E201] Trailing whitespace</failure>


[E201]尾随空格