Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions eng/common/pipelines/templates/steps/save-package-properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,26 @@ steps:
pwsh: true
workingDirectory: '${{ parameters.WorkingDirectory }}'

- task: Powershell@2
displayName: Save package properties filtered for PR
inputs:
filePath: ${{ parameters.ScriptDirectory }}/Save-Package-Properties.ps1
arguments: >
-PrDiff '${{ parameters.DiffDirectory }}/diff.json'
-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: |
$changedServices = (Get-Content -Path '${{ parameters.DiffDirectory }}/diff.json' -Raw | ConvertFrom-Json).ChangedServices
$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."
Expand All @@ -55,15 +70,6 @@ steps:
displayName: Upload tags.json with changed services
workingDirectory: '${{ parameters.WorkingDirectory }}'

- task: Powershell@2
displayName: Save package properties filtered for PR
inputs:
filePath: ${{ parameters.ScriptDirectory }}/Save-Package-Properties.ps1
arguments: >
-PrDiff '${{ parameters.DiffDirectory }}/diff.json'
-OutDirectory '${{ parameters.PackageInfoDirectory }}'
pwsh: true
workingDirectory: '${{ parameters.WorkingDirectory }}'
- ${{ else }}:
- task: Powershell@2
displayName: Save package properties
Expand Down