go-junit-report icon indicating copy to clipboard operation
go-junit-report copied to clipboard

Publishing Test Results in Azure Pipelines gives invalid character error

Open Divya1388 opened this issue 5 years ago • 3 comments

Configured a pipeline to test and publish results. The test is scripted to test a terraform Plan output. when running the tasks: go get -u github.com/jstemmer/go-junit-report go test -v -timeout 60m 2>&1 | go-junit-report > report.xml and Publish test results The pipline passes but the publish test result task give the following error ##[warning]Failed to read D:\a\1\go\src\s***\CentralUS\Global\VirtualNetwork\test\report.xml. Error : '.', hexadecimal value 0x00, is an invalid character. Line 2, position 1.. No build level attachments to publish. Finishing: Publish Test Results D:\a\1\go\src\s**\report.xml

Divya1388 avatar Nov 19 '19 01:11 Divya1388

The Publish test results throws error on Windows agent with Error : '.', hexadecimal value 0x00, is an invalid character. Line 2, position 1.. It does not give error on Linux agent

Divya1388 avatar Dec 06 '19 02:12 Divya1388

Hi, I am facing the same issue. Did you find a solution to this?

divyanshidm avatar Mar 03 '20 11:03 divyanshidm

I was able to resolve this with something like the following:

<code here to generate the report in the wrong encoding>
Get-Content report.xml -Encoding Unicode | Set-Content -Encoding UTF8 report_utf8.xml

I had to do a similar thing when using Terratest and the terratest_log_parser on Windows:

go test -v -timeout 60m | tee -Variable content
$content | Set-Content -Encoding utf8 test_output.log
terratest_log_parser -testlog test_output.log -outputdir test_output

I don't have the same problem when running these commands on Linux:

go test -v -timeout 30m | tee test_output.log
terratest_log_parser -testlog test_output.log -outputdir test_output

Of course, you would then use the PublishTestResults@2 Azure DevOps task to publish targeting the properly encoded output file.

jsoconno avatar Sep 16 '21 17:09 jsoconno