Skip to content

Commit 7e3b47d

Browse files
azure-sdkraych1Copilot
authored
Sync eng/common directory with azure-sdk-tools for PR 13202 (#54325)
* Added optional artifact list to filter the package info to be returned * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * return full package info if the input artifact list is empty * Fixed hashset issue * Added artifacts parameter --------- Co-authored-by: ray chen <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 52c1be3 commit 7e3b47d

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

eng/common/pipelines/templates/steps/daily-dev-build-variable.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# is used when this pipeline is going to be generating and publishing daily dev builds.
33
parameters:
44
ServiceDirectory: ''
5+
Artifacts: []
56
Condition: succeeded()
67
steps:
78
- ${{if ne(parameters.ServiceDirectory, '')}}:
@@ -11,6 +12,7 @@ steps:
1112
arguments: >
1213
-ServiceDirectory ${{parameters.ServiceDirectory}}
1314
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
15+
-artifactList @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json | Select-Object -ExpandProperty name)
1416
pwsh: true
1517
workingDirectory: $(Pipeline.Workspace)
1618
displayName: Dump Package properties

eng/common/scripts/Save-Package-Properties.ps1

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ package properties JSON file. If the package properties JSON file already
3030
exists, read the Version property from the existing package properties JSON file
3131
and set that as the Version property for the new output. This has the effect of
3232
"adding" a DevVersion property to the file which could be different from the
33-
Verison property in that file.
33+
Version property in that file.
34+
35+
.PARAMETER artifactList
36+
Optional array of artifact names to filter the package properties. Only packages
37+
with artifact names matching entries in this list will be processed.
3438
#>
3539

3640
[CmdletBinding()]
@@ -39,7 +43,8 @@ Param (
3943
[Parameter(Mandatory = $True)]
4044
[string] $outDirectory,
4145
[string] $prDiff,
42-
[switch] $addDevVersion
46+
[switch] $addDevVersion,
47+
[array] $artifactList
4348
)
4449

4550
. (Join-Path $PSScriptRoot common.ps1)
@@ -132,6 +137,38 @@ if (-not (Test-Path -Path $outDirectory))
132137
New-Item -ItemType Directory -Force -Path $outDirectory | Out-Null
133138
}
134139

140+
if ($artifactList)
141+
{
142+
# Filter out null, empty, or whitespace-only entries
143+
$filteredArtifacts = @($artifactList | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
144+
145+
if ($filteredArtifacts.Count -eq 0)
146+
{
147+
Write-Warning "Artifact list contains no valid entries"
148+
}
149+
else
150+
{
151+
Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')"
152+
$artifactSet = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
153+
foreach ($artifact in $filteredArtifacts) {
154+
$artifactSet.Add($artifact) | Out-Null
155+
}
156+
157+
# Warn about packages missing ArtifactName property
158+
$missingArtifactName = $allPackageProperties | Where-Object { $_.PSObject.Properties.Name -notcontains 'ArtifactName' }
159+
foreach ($pkg in $missingArtifactName) {
160+
Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering."
161+
}
162+
$allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) }
163+
164+
if (!$allPackageProperties)
165+
{
166+
Write-Error "No packages found matching the provided artifact list"
167+
exit 1
168+
}
169+
}
170+
}
171+
135172
foreach ($pkg in $allPackageProperties)
136173
{
137174
if ($pkg.Name)

0 commit comments

Comments
 (0)