Skip to content

Commit c76aa44

Browse files
azure-sdkscbeddhallipr
authored
Sync eng/common directory with azure-sdk-tools for PR 9328 (Azure#38325)
* 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 <[email protected]> Co-authored-by: Scott Beddall <[email protected]> Co-authored-by: Patrick Hallisey <[email protected]>
1 parent 37a458b commit c76aa44

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

eng/common/pipelines/templates/steps/save-package-properties.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ steps:
3232
-ArtifactPath '${{ parameters.DiffDirectory }}'
3333
pwsh: true
3434

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

eng/common/scripts/Generate-PR-Diff.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function Get-ChangedServices
2828
[string[]] $ChangedFiles
2929
)
3030

31-
$changedServices = $ChangedFiles | Foreach-Object { if ($_ -match "sdk/([^/]+)") { $matches[1] } } | Sort-Object -Unique
31+
[string[]] $changedServices = $ChangedFiles | Foreach-Object { if ($_ -match "sdk/([^/]+)") { $matches[1] } } | Sort-Object -Unique
3232

33-
return $changedServices
33+
return , $changedServices
3434
}
3535

3636
if (!(Test-Path $ArtifactPath))

0 commit comments

Comments
 (0)