TFS构建向摘要写入消息

问题描述 投票:0回答:1

我想在构建摘要中添加一条消息(链接)(也可以是一个新的部分,并不重要):

enter image description here

基于此: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)无法上传任务附件文件,未指定附件文件位置或磁盘上不存在附件文件

如何在构建的摘要中添加text / link / 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 ## [错误]无法上传任务附件文件,未指定附件文件位置或磁盘上不存在附件文件

enter image description here

编辑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

enter image description here

enter image description here

tfs msbuild azure-devops tfsbuild
1个回答
1
投票

“hellomessage”无法工作,因为您必须提供文件路径而不仅仅是字符串。

在尝试使用PowerShell脚本时,文件路径中存在问题。

我不知道sourcesFolder的价值是什么,我无法理解什么是+ file ...

我试图以这种方式连接文件路径:

$filePath = $(Build.SourcesDirectory)\test.html
# Verify the path is correct:
Write-Host $filePath
# Output: D:\a\1\s\test.html

然后我以这种方式将文件上传到“摘要”页面:

Write-Host "##vso[task.uplaodsummary]$filePath"

上传成功,test.html存在于构建摘要页面中。

因此,在您的情况下,您必须检查文件路径并修复它,之后上传将起作用(您也可以尝试放置硬编码路径并检查它是否有效)。

P.S - task.uploadsuammrytask.addattachment type=Distributedtask.Core.Summary的捷径。

© www.soinside.com 2019 - 2024. All rights reserved.