简体   繁体   English

AzureDevops PowerShell和任务

[英]AzureDevops PowerShell and Tasks

I currently have a VSTS/AzureDevOps task extension which is composed of a json file and a ps1 script. 我目前有一个VSTS / AzureDevOps任务扩展,它由一个json文件和一个ps1脚本组成。 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. json文件基本上规定了输入,而ps1脚本确实实现了它(它运行一些测试。)我想扩展此任务以在管道中上传测试结果,AzureDevops具有方便的“发布测试结果”,但这就是YAML事情。

Is there any way to get the same functionality as using the premade task, but just via PowerShell? 有什么方法可以通过使用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? 我认为执行此操作的唯一其他方法是使用AzureDevops REST API?

I tested artifact.upload following the example given here . 我按照此处给出的示例测试了artifact.upload 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. 并发现将文件发布到工件,并且无法在构建Summary的“ Tests页面中显示测试结果,如下图所示。 在此处输入图片说明

Tested with artifact.upload with below script in powershell. 使用powershell中的以下脚本对artifact.upload进行了测试。

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. 我尝试使用纯Powershell做到这一点,似乎是一项艰巨的工作。 If you only want to publish it to azure pipeline and want to show the results like above pic. 如果您只想将其发布到azure管道,并想要显示如上图所示的结果。 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. 您可以将xml文件保存到主机代理上的某个位置,然后使用“ Publish Test Result任务来执行xml测试结果。 This seems like a easier workaround. 这似乎是一个更简单的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 纽曼与 AzureDevOps + Powershell - Newman with AzureDevOps + Powershell 如何在 Powershell 中使用 RestApi 从 AzureDevOps 获取工作项 - How to get the workitems from AzureDevOps with RestApi in Powershell 如何通过 AWS 工具使用来自 AzureDevops 的 Powershell 7 - How to use Powershell 7 from AzureDevops with AWS Tools AzureDevOps Powershell 任务命令行参数在 Powershell 脚本中未正确呈现 - AzureDevOps Powershell task command line parameters are not properly rendered in Powershell script AzureDevOps:将任务变量作为对象传递给后续的 powershell 任务类型 - AzureDevOps: Pass task variable to subsequent powershell task type as Object nuget(powershell 或 AzureDevOps 任务)中的 .config 文件的令牌替换 - Token replacement of .config files inside a nuget (powershell or AzureDevOps task) 在 Azuredevops 发布管道中使用 powershell 脚本执行 SSIS 作业 - Executing SSIS job using powershell script in Azuredevops release pipeline Powershell脚本任务output的AzureDevOps Pipeline变量赋值 - AzureDevOps Pipeline variable assignment of Powershell script task output AzureDevOps 任务中 Powershell Start-Process 上的访问被拒绝 - Access Denied on Powershell Start-Process within AzureDevOps task Powershell计划任务有冲突吗? - Powershell Scheduled Tasks conflicts?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM