【发布时间】:2019-09-16 08:16:38
【问题描述】:
我想在构建摘要中添加一条消息(链接)(也可以是新部分,没关系):
基于此:https://blogs.objectsharp.com/post/2017/04/25/Writing-to-the-Build-Report-in-TFS-2015.aspx,
我在我的 Powershell 脚本中添加了这一行:
Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]"
但是我收到一条错误消息:
无法处理命令'##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]' 成功地。请参考文档 (http://go.microsoft.com/fwlink/?LinkId=817296) 无法上传任务 附件文件,未指定附件文件位置或 磁盘上不存在附件文件
如何在构建摘要中添加文本/链接/href? (powershell还是其他方法?)
编辑: 请参阅下面的编辑。我在构建步骤中从 PowerShell 运行此脚本:
$path = $sourcesFolder + "file:///C:/Temp/dotCover-xunit.html"
Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]$path"
编辑2:(尝试了一个简单的文本)
function AddSummaryMessage{
$filePath = "somestring"
Write-Host "##vso[task.uplaodsummary]$filePath"
}
还尝试将“hellomessage”作为字符串:
错误信息:
2019-04-27T01:49:01.1513980Z ##[错误]无法处理命令 '##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]hellomessage' 成功地。请参考文档 (http://go.microsoft.com/fwlink/?LinkId=817296) 2019-04-27T01:49:01.1516289Z ##[错误]无法上传任务附件 文件,未指定附件文件位置或未指定附件文件 存在于磁盘上
编辑 3:
function AddSummaryMessage{
$file = Get-ChildItem $outputFolder -name "dotcover.html";
if ($file){
LogMessage("Found dotcover report file: " + ($outputFolder + $file))
$path = ($outputFolder + $file)
Write-Host "##vso[task.uplaodsummary]$path"
}
}
OUTPUT:
9:27:01 AM add summary message
9:27:01 AM Found dotcover report file: C:\Builds\tfsbuilddev02\Agent1\110\s\dotCover\dotcover.html
【问题讨论】:
-
您好像错过了
Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=ObjectSharp;]*$Tempfile*"的消息 -
试过了。没用
-
我已经尝试了您提供的示例,它对我有用。你能提供更多信息吗?可能是错误和代码的屏幕截图。
-
请参阅编辑
标签: tfs msbuild azure-devops tfsbuild