TFS构建写入消息链接以进行报告

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

如何在TFS构建摘要中添加可点击链接?

enter image description here

Powershell代码:

function AddSummaryMessage{
    $file = Get-ChildItem $outputFolder -name "dotcover.html";
    if ($file){

        $linkPath = "file://///" + $outputFolder.replace("C:\", "").replace("\", "/") + "dotcover.html"
        $linkPath = "<a href="""+ $linkPath +""">view dotCover report</a>"
        LogMessage("File path: " + $linkPath)

        $linkPath | Out-File -FilePath ($outputFolder + "link.txt") -Append
        $file = Get-ChildItem $outputFolder -name "link.txt";
        LogMessage("link file: " + ($outputFolder + $file))
        $path = ($outputFolder + $file)
        Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=DotCover Report;]$path"
    }
}

该文件确实存在并被创建。然后在我的link.txt中我有这样的文字:

<a href="file://///tfsbuilddev03/Builds/tfsbuilddev03/Agent1/6/s/dotCover/dotcover.html">view dotCover report</a>

然而,当我将鼠标悬停在它上面时,它指向其他地方:enter image description here

顺便说一句,将此字符串(从link.txt文件)复制到浏览器,可以正确打开html文件:

file://///tfsbuilddev03/Builds/tfsbuilddev03/Agent1/6/s/dotCover/dotcover.html
tfs tfsbuild
1个回答
0
投票

也许你应该看看这个答案:How can I create a link to a local file on a locally-run web page?

这可能是你的File URI的一个问题。托管文件在哪里?请注意关于URI的部分,如果没有指定,它会对主机做出假设。它出现在远程机器上,似乎是tfsbuilddev03。如果那是主机,你可以把它作为URI的主机部分,即file:////tfsbuilddev03/Builds/tfsbuilddev03/Agent1/6/s/dotCover/dotcover.html

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