[d16-9] [VSTS][CI] Add links with the generated pkgs. (#10489)

We do have the pkgs when we have not been triggered by a PR.


Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
This commit is contained in:
VS MobileTools Engineering Service 2 2021-01-21 12:18:53 -08:00 коммит произвёл GitHub
Родитель 35833cd28b
Коммит b252d8c232
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -381,7 +381,7 @@ function New-GitHubSummaryComment {
$TestSummaryPath,
[string]
$Artifacts
$Artifacts=""
)
$envVars = @{
@ -410,7 +410,8 @@ function New-GitHubSummaryComment {
# we did generate an index with the files in vsdrops
$sb.AppendLine("* [Html Report (VSDrops)]($Env:VSDROPS_INDEX)")
}
if ($Artifacts) {
if (-not [string]::IsNullOrEmpty($Artifacts)) {
Write-Host "Parsing artifacts"
if (-not (Test-Path $Artifacts -PathType Leaf)) {
$sb.AppendLine("Path $Artifacts was not found!")
} else {
@ -418,12 +419,19 @@ function New-GitHubSummaryComment {
$json = Get-Content $Artifacts | ConvertFrom-Json
if ($json.Count -gt 0) {
$sb.AppendLine("<details><summary>View packages</summary>")
$sb.AppendLine("") # no new line results in a bad rendering in the links
foreach ($a in $json) {
$url = $a.url
if ($url.EndsWith(".pkg") -or $url.EndsWith(".nupkg")) {
try {
$fileName = $a.url.Substring($a.url.LastIndexOf("/" + 1))
$sb.AppendLine("* [$fileName]($($a.url))")
$fileName = $a.url.Substring($a.url.LastIndexOf("/") + 1)
Write-Host "Adding link for $fileName"
if ($a.url.Contains("notarized")) {
$link = "* [$fileName (notarized)]($($a.url))"
} else {
$link = "* [$fileName]($($a.url))"
}
$sb.AppendLine($link)
} catch {
Write-Host "Could not get file name for url $url"
}
@ -434,6 +442,8 @@ function New-GitHubSummaryComment {
$sb.AppendLine("No packages found.")
}
}
} else {
Write-Host "Artifacts were not provided."
}
$headerLinks = $sb.ToString()

Просмотреть файл

@ -79,7 +79,11 @@ steps:
$env:VSDROPS_INDEX="$Env:VSDROPSPREFIX/$Env:BUILD_BUILDNUMBER/$Env:BUILD_BUILDID/$Env:DEVICE_PREFIX/;/tests/vsdrops_index.html"
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\GitHub.psm1
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\VSTS.psm1
if ($Env:BUILD_PACKAGE -eq "True") {
$buildReason = "$(Build.Reason)"
$buildSourceBranchName = "$(Build.SourceBranchName)"
if ($buildReason -ne "PullRequest" -or $Env:BUILD_PACKAGE -eq "True") {
Write-Host "Json path is $Env:ARTIFACTS_JSON_PATH"
$response = New-GitHubSummaryComment -Context "$Env:CONTEXT" -TestSummaryPath "$Env:TESTS_SUMMARY" -Artifacts "$Env:ARTIFACTS_JSON_PATH"
Write-Host $response