简体   繁体   中英

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?

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. 在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM