【发布时间】:2020-05-08 17:14:48
【问题描述】:
我有一个创建report.xml 文件的容器,我希望使用该文件在Azure 中创建测试报告。
我想在管道期间执行此操作,但我错过了如何在 Azure 管道期间获取此文件。
在存储帐户中下载文件并在管道期间将其用于测试结果的方法是什么?
【问题讨论】:
标签: azure-devops azure-storage azure-pipelines
我有一个创建report.xml 文件的容器,我希望使用该文件在Azure 中创建测试报告。
我想在管道期间执行此操作,但我错过了如何在 Azure 管道期间获取此文件。
在存储帐户中下载文件并在管道期间将其用于测试结果的方法是什么?
【问题讨论】:
标签: azure-devops azure-storage azure-pipelines
如果我理解的话,您想从管道中的 blob 存储中复制文件吗?
为此,您可以将Azure Cli task 与此command 一起使用:
az storage blob download
但是你能解释一下这个use it on a Test Result during the pipeline? 是什么意思吗?
【讨论】:
尝试使用 Azure Powershell 处理从 Azure 存储 Blob 获取文件:
$storage = Get-AzStorageAccount -ResourceGroupName xxx -Name yyy
$ctx = $storageAccount.Context
# download blob
Get-AzStorageblobcontent -Blob "report.xml" `
-Container $containerName `
-Destination " $(System.DefaultWorkingDirectory)" `
-Context $Context
根据这个问题:How to copy a file from Azure Storage fileshare to Release pipeline agent
您似乎试图从 Azure 文件共享(不是 blob)下载文件,请参考我在该链接中的回复。
【讨论】:
经过一番挖掘,这就是解决方案。
我所做的是在容器实例期间将存储卷安装到生成报告的容器中。
随后在管道中,我已将存储帐户中存储的文件复制到管道代理。
$storageAcct = Get-AzStorageAccount -ResourceGroupName XXX -Name YYY
Get-AzStorageFileContent -Context $storageAcct.context -ShareName "Sharename" -Path "report.xml" -Destination $(System.DefaultWorkingDirectory)
然后,在发布管道期间使用测试报告器时,只需从代理获取文件即可。
【讨论】: