TFS构建写入消息以进行总结 [英] TFS build write message to summary

查看:92
本文介绍了TFS构建写入消息以进行总结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want add a message (link) in the build summary (can be a new section also, doesn't really matter):

基于此: https://blogs.objectsharp.com/post/2017/04/25/Writing-to-the-Build-Report-in-TFS-2015.aspx

我已经在Powershell脚本中添加了这一行:

I've added this line in my Powershell script:

Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]" 

但是我收到一条错误消息:

However I get an error message:

无法处理命令'## vso [task.addattachment type = Distributedtask.Core.Summary; name = DotCover结果;]' 成功地.请参考文件 ( http://go.microsoft.com/fwlink/?LinkId=817296 )无法上传任务 附件文件,未指定附件文件位置,或 磁盘上不存在附件文件

Unable to process command '##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296) Cannot upload task attachment file, attachment file location is not specified or attachment file not exist on disk

如何在构建摘要中添加text/link/href? (PowerShell或其他方法?)

How would one add a text/link/href in the summary of the build? (powershell or other method?)

请参见下面的编辑.我在构建步骤中从PowerShell运行此脚本:

Please see edit below. I run this script from PowerShell during the build step:

$path = $sourcesFolder + "file:///C:/Temp/dotCover-xunit.html"
Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]$path"

编辑2 :(尝试了一个简单的文字)

EDIT 2: (tried a simple text)

function AddSummaryMessage{
	$filePath = "somestring"
	Write-Host "##vso[task.uplaodsummary]$filePath"
}

还尝试使用"hellomessage"作为字符串:

also tried with "hellomessage" as string in there:

错误消息:

2019-04-27T01:49:01.1513980Z ## [错误]无法处理命令 '## vso [task.addattachment type = Distributedtask.Core.Summary; name = DotCover结果;] hellomessage' 成功地.请参考文件 ( http://go.microsoft.com/fwlink/?LinkId=817296 ) 2019-04-27T01:49:01.1516289Z ## [错误]无法上传任务附件 文件,附件文件位置未指定或附件文件未指定 存在于磁盘上

2019-04-27T01:49:01.1513980Z ##[error]Unable to process command '##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Results;]hellomessage' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296) 2019-04-27T01:49:01.1516289Z ##[error]Cannot upload task attachment file, attachment file location is not specified or attachment file not exist on disk

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

推荐答案

问候消息"无法工作,因为您必须提供文件路径,而不仅仅是字符串.

The "hellomessage" can't work because you must give a file path and not just a string.

尝试使用PowerShell脚本时,文件路径出现问题.

In the attempt with the PowerShell script you have a problem in the file path.

我不知道sourcesFolder的值是什么,我不明白什么是+ file ....

I don't know what the value of the sourcesFolder and I can't understand what is the + file ....

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

I tried to concatenate the file path in this way:

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

我以这种方式将文件上传到摘要"页面:

And I upload the file to the Summary page in this way:

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

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

The upload succeeded and the test.html exist in the build summary page.

因此,在您的情况下,您必须检查文件路径并进行修复,然后上传就可以了(您也可以尝试添加硬编码的路径并检查其是否有效).

So in your case you must to check the file path and fix it, after it the upload will work (you can try also put hard coded path and check if it works).

PS -task.uploadsuammrytask.addattachment type=Distributedtask.Core.Summary的简写.

这篇关于TFS构建写入消息以进行总结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆