Svend
Svend

Reputation: 8158

AzureDevops PowerShell and Tasks

I currently have a VSTS/AzureDevOps task extension which is composed of a json file and a ps1 script. The json file basically stipulates the inputs and the ps1 script does it's thing (it runs some tests.) I want to extend this task to upload test results in the pipeline, and AzureDevops has the handy "Publish Test Results", but thats a YAML thing.

Is there any way to get the same functionality as using the premade task, but just via PowerShell? I looked at things like this but I could not find something obvious.

I assume the only other route for doing this would be somehow using the AzureDevops REST api?

Upvotes: 1

Views: 420

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30313

I tested artifact.upload following the example given here. and found out it published the file to the artifacts, and can not show the test result in the Tests page of build Summary as shown in below pic. enter image description here

Tested with artifact.upload with below script in powershell.

echo "##vso[artifact.upload containerfolder=testresult;artifactname=uploadedresult;]$(Agent.BuildDirectory)\TestResult\WS-LEVIL-01_WS-LEVIL-01_2019-09-05_11_36_44.trx"

the task log showed as below:

Uploading 1 files
File upload succeed.
Upload 'C:\agent\_work\2\TestResult\WS-LEVIL-01_WS-LEVIL-01_2019-09-05_11_36_44.trx' to file container: '#/3389084/testresult'
Associated artifact 209 with build 595
Async Command End: Upload Artifact

I tried to do this with pure powershell and seemed be a hard work. If you only want to publish it to azure pipeline and want to show the results like above pic. You can save the xml file to a place on the host agent and then use Publish Test Result task to pulish the xml test result. This seems like a easier workaround.

Upvotes: 2

Related Questions