1
votes

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

enter image description here

Based on this: https://blogs.objectsharp.com/post/2017/04/25/Writing-to-the-Build-Report-in-TFS-2015.aspx,

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:

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

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

EDIT: 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"

EDIT 2: (tried a simple text)

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

also tried with "hellomessage" as string in there:

Error message:

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

enter image description here

EDIT 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

1
looks like you are missing the message Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=ObjectSharp;]*$Tempfile*" Amit Baranes
tried that. didn't workShaneKm
I have tried the example you provide and it worked for me. can you please provide more information ? maybe a screenshot of error and the code.Amit Baranes
please see EDITShaneKm

1 Answers

1
votes

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

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

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"

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).

P.S - The task.uploadsuammry is a short hand to task.addattachment type=Distributedtask.Core.Summary.