From 8ce6da864540aab5b95fd2ec3950b15ac00aa9e3 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 16 May 2025 14:29:07 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 10657 (#6580) * ensure the directory that gets logged is the actual changed package's service directory --------- Co-authored-by: Scott Beddall --- .../steps/save-package-properties.yml | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/eng/common/pipelines/templates/steps/save-package-properties.yml b/eng/common/pipelines/templates/steps/save-package-properties.yml index 65966d1c6..d3a1177ac 100644 --- a/eng/common/pipelines/templates/steps/save-package-properties.yml +++ b/eng/common/pipelines/templates/steps/save-package-properties.yml @@ -41,20 +41,6 @@ steps: pwsh: true workingDirectory: '${{ parameters.WorkingDirectory }}' - # 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 - workingDirectory: '${{ parameters.WorkingDirectory }}' - - task: Powershell@2 displayName: Save package properties filtered for PR inputs: @@ -64,6 +50,26 @@ steps: -OutDirectory '${{ parameters.PackageInfoDirectory }}' pwsh: true workingDirectory: '${{ parameters.WorkingDirectory }}' + + # 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: | + $changedPackages = Get-ChildItem -Recurse -Filter *.json "${{ parameters.PackageInfoDirectory }}" ` + | ForEach-Object { Get-Content -Raw $_ | ConvertFrom-Json } + + $changedServices = $changedPackages | Where-Object { $_.IncludedForValidation -eq $false } ` + | Select-Object -ExpandProperty ServiceDirectory | Sort-Object -Unique + + 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 + workingDirectory: '${{ parameters.WorkingDirectory }}' + - ${{ else }}: - task: Powershell@2 displayName: Save package properties