1

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?

The Furious Bear
  • 592
  • 4
  • 16
  • 31
  • So, the build is done but you want to come afterwards and add the summary and change the status? Any reason you wouldn't just block on the tests to finish? What version of tfs? – Matt Oct 27 '20 at 22:54
  • Trying to execute remote functional tests asynchronously in order to speed up builds and reduce congestion on build agents. – The Furious Bear Oct 28 '20 at 11:20
  • API version 3.2, TFS 2017 – The Furious Bear Oct 28 '20 at 13:37
  • Can you describe a little the remote piece where the tests run? How are you triggering those? – Matt Oct 28 '20 at 13:59
  • The process kicks off the VsTest.console.exe from a PowerShell script on the remote server. My plan was to add the scripted functionality to update the build at the end of my test execution script, depending on the test outcome. – The Furious Bear Oct 28 '20 at 14:06
  • I'm guessing you are trying to optimize the use of your allotment of parallel job agents. If that doesn't really matter and you care specifically about the build agents ... you could just install the TFS agent on the remote server and register it with a certain capability. You would have to split your process into multiple phases so you could target the different capability, but then you can block on the tests and the build agent is freed up. – Matt Oct 28 '20 at 17:56

1 Answers1

2

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.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • Okay, understood; no API to publish the TRX results file retroactively. The whole purpose here is to execute remote functional tests asynchronously in order to reduce build execution times and thus reduce congestion on build agents. I guess there are a couple of workarounds I could consider in this case: - Update the build result to 'Failed' in the event of test failure - Add link to TRX file location (repository of some type) to build log. – The Furious Bear Oct 28 '20 at 13:39
  • 1
    Not addressed here, but I am pretty sure the build status is immutable once the build completes. I don't think even they part will work. – Matt Oct 28 '20 at 13:57
  • Thanks for responses. According to TFS 2017 documentation here, https://learn.microsoft.com/en-us/azure/devops/integrate/previous-apis/build/builds?view=tfs-2017, build status is indeed immutable once the build is complete. Regarding build result, there is no mention that this cannot be updated... – The Furious Bear Oct 28 '20 at 14:00