devOps_7
devOps_7

Reputation: 33

How to publish vs test results back in the same azure build pipeline when all the test cases are run through remote powershell job

Can anyone guide me through the process, if it is already available in azure devops build pipeline?
I want to achieve the following tasks:

  1. Run test cases on azure windows VM through remote powershell. (done and accomplished)
  2. generate test file (say .trx) after successful running the test script through vstest.console (done and accomplished)
  3. build or publish back the test results file in repo or somehow include results in pipeline to publish. (stuck in this step)

what I have accomplished is I can push back results to the repository and publish it in new pipeline, Is this process ok or there is some other way to accomplish this same task? If I pushed trx to repository a new build is triggered because of the changes in the repo and thus this is not the proper or standard way of doing this even with some custom CI trigger rules which can exclude trx file for automation.

Long question short : 1. How to publish test results for the same build event, if the software is deployed and tested on VM (through remote powershell)?

Upvotes: 1

Views: 1954

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30313

Update:

Since copy tasks donot work out. There is a workaround to move the test results from azure vm to azure build agents.

You can create a server(azure web app) and upload the test results to the web server(using kudu api).

Then you can add a powershell task to call kudu api to download the test results to your azure agents. Please check this thread for full scripts example, and here for more information about kudu api.


In you build pipeline you can add a Remote copy task(or Copy files over SSH task) to copy the test results files from the VM to the folder (eg. $(Agent.BuildDirectory)\TestResults) on your agent. For below example.

enter image description here

You need to copy all the generated result files.

enter image description here

Then you need to add a publish test result task to publish the test result.

enter image description here

You will most likely encounter below warning saying .log,.html not found when executing your publish test result task.

enter image description here

Above warning happens is because when you copy the test result files from remote vm to your agent, the path to those files changes. You need to change the files path in trx file to its right place($(Agent.BuildDirectory)\TestResults) in your agent.

enter image description here

You can replace the file path in trx file by RegEx Match & Replace.

enter image description here

The tasks I used in above steps is listed as below.

enter image description here

If all above steps are set correctly, you will then see the test results in the Tests tab after your build run is completed

enter image description here

Upvotes: 1

Related Questions