Sync eng/common directory with azure-sdk-tools for PR 9328 (#23692)

* ensure that ChangedServices value within the generated pr diff is always properly an array of strings
* upload the changed services as an attachment named AdditionalTags in save-package-properties.yml, to allow PipelineWitness to tag public builds during log processing

---------

Co-authored-by: Scott Beddall <scbedd@microsoft.com>
Co-authored-by: Scott Beddall <45376673+scbedd@users.noreply.github.com>
Co-authored-by: Patrick Hallisey <hallipr@gmail.com>
This commit is contained in:
Azure SDK Bot 2024-11-12 14:55:07 -08:00 коммит произвёл GitHub
Родитель 3217d2ef0b
Коммит 353cd4e149
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 15 добавлений и 2 удалений

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

@ -32,6 +32,19 @@ steps:
-ArtifactPath '${{ parameters.DiffDirectory }}'
pwsh: true
# When running in PR mode, we want the detected changed services to be attached to the build as tags.
# However, the public identity does not have the permissions to attach tags to the build.
# Instead, we will save the changed services to a file, attach it as an attachment for PiplineWitness to pick up and utilize.
- pwsh: |
$changedServices = (Get-Content -Path '${{ parameters.DiffDirectory }}/diff.json' -Raw | ConvertFrom-Json).ChangedServices
if ($changedServices) {
Write-Host "Attaching changed service names to the build for additional tag generation."
$changedServices | ConvertTo-Json -AsArray | Out-File -FilePath $(System.DefaultWorkingDirectory)/tags.json -Encoding utf8
Write-Host '##vso[task.addattachment type=AdditionalTags;name=AdditionalTags;]$(System.DefaultWorkingDirectory)/tags.json'
}
displayName: Upload tags.json with changed services
- task: Powershell@2
displayName: Save package properties filtered for PR
inputs:

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

@ -28,9 +28,9 @@ function Get-ChangedServices
[string[]] $ChangedFiles
)
$changedServices = $ChangedFiles | Foreach-Object { if ($_ -match "sdk/([^/]+)") { $matches[1] } } | Sort-Object -Unique
[string[]] $changedServices = $ChangedFiles | Foreach-Object { if ($_ -match "sdk/([^/]+)") { $matches[1] } } | Sort-Object -Unique
return $changedServices
return , $changedServices
}
if (!(Test-Path $ArtifactPath))