0

How can I add a clickable link to summary of TFS build?

enter image description here

Powershell Code:

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"
    }
}

The file does exist and gets created. Then in my link.txt I have this text:

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

However when I hover over it it points somewhere else: enter image description here

BTW, copying this string (from the link.txt file) to browser, does open html file correctly:

file://///tfsbuilddev03/Builds/tfsbuilddev03/Agent1/6/s/dotCover/dotcover.html
ShaneKm
  • 20,823
  • 43
  • 167
  • 296

1 Answers1

0

Perhaps you should check out this SO answer: How can I create a link to a local file on a locally-run web page?

It may be an issue with your File URI. Where is the file hosted? Note the part about the URI where it makes an assumption about the host if it's not specified. It appears on the remote machine, which seems to be tfsbuilddev03. If that's the host, you could make it the host part of the URI, i.e. file:////tfsbuilddev03/Builds/tfsbuilddev03/Agent1/6/s/dotCover/dotcover.html

pmiller3
  • 161
  • 5