TFS 构建将消息写入摘要
TFS build write message to summary
我想在构建摘要中添加一条消息 (link)(也可以是一个新部分,没关系):
基于此: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;]"
但是我收到一条错误消息:
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 或其他方法?)
编辑:
请参阅下面的编辑。我在构建步骤中 运行 来自 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 ##[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
编辑 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\Agent10\s\dotCover\dotcover.html
"hellomessage" 无法工作,因为您必须 提供文件路径而不仅仅是字符串。
尝试使用 PowerShell 脚本时,文件路径出现问题。
我不知道 sourcesFolder
的值是什么,我不明白 + file ...
是什么。
我尝试以这种方式连接文件路径:
$filePath = $(Build.SourcesDirectory)\test.html
# Verify the path is correct:
Write-Host $filePath
# Output: D:\a\s\test.html
并且我是这样上传文件到Summary页面的:
Write-Host "##vso[task.uplaodsummary]$filePath"
上传成功并且 test.html
存在于构建摘要页面中。
因此,在您的情况下,您必须检查文件路径并修复它,然后上传才能正常工作(您也可以尝试输入硬编码路径并检查它是否有效)。
P.S - task.uploadsuammry
是 task.addattachment type=Distributedtask.Core.Summary
的缩写。
我想在构建摘要中添加一条消息 (link)(也可以是一个新部分,没关系):
基于此: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;]"
但是我收到一条错误消息:
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 或其他方法?)
编辑: 请参阅下面的编辑。我在构建步骤中 运行 来自 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 ##[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
编辑 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\Agent10\s\dotCover\dotcover.html
"hellomessage" 无法工作,因为您必须 提供文件路径而不仅仅是字符串。
尝试使用 PowerShell 脚本时,文件路径出现问题。
我不知道 sourcesFolder
的值是什么,我不明白 + file ...
是什么。
我尝试以这种方式连接文件路径:
$filePath = $(Build.SourcesDirectory)\test.html
# Verify the path is correct:
Write-Host $filePath
# Output: D:\a\s\test.html
并且我是这样上传文件到Summary页面的:
Write-Host "##vso[task.uplaodsummary]$filePath"
上传成功并且 test.html
存在于构建摘要页面中。
因此,在您的情况下,您必须检查文件路径并修复它,然后上传才能正常工作(您也可以尝试输入硬编码路径并检查它是否有效)。
P.S - task.uploadsuammry
是 task.addattachment type=Distributedtask.Core.Summary
的缩写。