Skip to content

Generated XML fails to parse using Jenkins JUnit Plugin #8755

Open
@bkhouri

Description

@bkhouri

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

When generating the XML files using swift test --xunit-output <file>, ingesting the generated files using Jenkins JUnit Plugin fails.

According to JENKINS-65438:

As reported in the plugin documentation JUnit supported schema are Ant junit and Maven Surefire
Schemas reports 3 digit for duration

This issue occurs with the XCTest and Swift Testing generated XML. Setting the time attribute on the testsuite element to have 3 decimal digits appears to allow Jenkins to parse the XML file.

Expected behavior

SwiftPM can generated an XML file that can be ingested using the Jenkins JUnit plugin.

Actual behavior

I created a Freestyle job that copies the XML file from a known location, to the workspace, and then publish the XML report.

using the attached XML file xunit.xml.txt (added the .txt extension to allow uploading to GitHub), which was produced using swift test --parallel <other options> --xunit-output unit.xml

/var/jenkins_home/workspace/run-swift-testing-tests-against-swiftlang-swift-package-manager
+ rm -rf generatedJUnitFiles xunit.xml
+ ls /src/swift-package-manager/xunit.xml
+ cp -v /src/swift-package-manager/xunit.xml .
'/src/swift-package-manager/xunit.xml' -> './xunit.xml'
+ ls -lrt
total 48
-rw-r--r-- 1 jenkins jenkins 48257 Jun  2 15:47 xunit.xml
INFO: Processing JUnit
INFO: [JUnit] - 1 test report file(s) were found with the pattern '*.xml' relative to '/var/jenkins_home/workspace/run-swift-testing-tests-against-swiftlang-swift-package-manager' for the testing framework 'JUnit'.
WARNING: The file '/var/jenkins_home/workspace/run-swift-testing-tests-against-swiftlang-swift-package-manager/xunit.xml' is an invalid file.
WARNING: At line 3 of file:/var/jenkins_home/workspace/run-swift-testing-tests-against-swiftlang-swift-package-manager/xunit.xml:cvc-pattern-valid: Value '171.327931208' is not facet-valid with respect to pattern '(([0-9]{0,3},)*[0-9]{3}|[0-9]{0,3})*(\.[0-9]{0,3})?' for type 'SUREFIRE_TIME'.
WARNING: At line 3 of file:/var/jenkins_home/workspace/run-swift-testing-tests-against-swiftlang-swift-package-manager/xunit.xml:cvc-attribute.3: The value '171.327931208' of attribute 'time' on element 'testsuite' is not valid with respect to its type, 'SUREFIRE_TIME'.
ERROR: Step ‘Publish xUnit test result report’ failed: The result file '/var/jenkins_home/workspace/run-swift-testing-tests-against-swiftlang-swift-package-manager/xunit.xml' for the metric 'JUnit' is not valid. The result file has been skipped.
Finished: FAILURE

Steps to reproduce

  1. Install Jenkins and the Jenkins JUnit plugin
  2. Configure a job that copies the attached XML File xunit.xml.txt (attachment includes .txt to allow GitHub to upload the file) and ingest it. See this attached sample Jenkins job config.xml.txt (attachment includes .txt to allow GitHub to upload the file)
  3. Run the job. it fails with an error.
  4. Apply the following diff to the file and try re-ingesting the job on Jenkins. Notice the time attribute on the testsuite element has 3 decimal digits.
diff --git a/xunit.xml b/xunit.xml
index d630200a5..f216591ce 100644
--- a/xunit.xml
+++ b/xunit.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuites>
-  <testsuite name="TestResults" errors="0" tests="360" failures="4" skipped="10" time="171.327931208">
+  <testsuite name="TestResults" errors="0" tests="360" failures="4" skipped="10" time="171.327">
     <testcase classname="QueryEngineTests.QueryEngineTests" name="simpleCaching()" time="41.543661333" />
     <testcase classname="QueryEngineTests.QueryEngineTests" name="filePathHashing()" time="41.5948975" />
     <testcase classname="_InternalTestSupportTests.TestGetBuildSystemArgs" name="nilArgumentReturnsEmptyArray()" time="40.2306615" />

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

❯ swift --version
Apple Swift version 6.2-dev (LLVM 9ae4b59a6edd27c, Swift eac419b8ca2dc36)
Target: arm64-apple-macosx15.0
Build config: +assertions

❯ uname -a
Darwin BKs-Work-M1Pro-MacBook-Pro-3.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 21:06:59 PDT 2025; root:xnu_development-11417.121.6~4/DEVELOPMENT_ARM64_T6000 arm64

Metadata

Metadata

Assignees

Labels

bugswift testChanges impacting `swift test` tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions