powershellresttfsbuildtrx

TFS build publish test results TRX via REST API & PowerShell


I have a TFS build process that incorporates asynchronous remote functional test executions. When the tests have finished executing, I want to publish the generated TRX file in the originating build summary and update the build status (if required).

I've been searching for awhile now and have so far been unsuccessful in finding exactly what I'm looking for: is it possible to publish the TRX file to the build summary via a PowerShell scripted REST API call?


Solution

  • I am afraid there is not a rest api available to publish the TRX file to the build summary page.

    During the pipeline execution, the tasks consume the trx file and read the test result to generate a report which you see on the build summary page. So even if you managed to upload the trx file afterwards, the trx file will not be processed and you cannot get test report on the build summary page.

    If your pipeline waits for the test execution to complete, you can try using scripts to copy the generated TRX file back to the local agent machine and published via publish tesk results task.

    If the pipeline finished before the test execution completed. You can create new pipeline to publish the trx file as workaround. But this will end up showing the test result in a different pipeline build summary page. If it is acceptable to you, you can copy the trx file back to the local agent machine and trigger the new pipeline via Build Queue rest api. You can also consider publishing the trx file to a git repo and add this git repo to the new pipeline as git source.