Sync eng/common directory with azure-sdk-tools for PR 13202 (#6861)
* Added optional artifact list to filter the package info to be returned * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * return full package info if the input artifact list is empty * Fixed hashset issue * Added artifacts parameter --------- Co-authored-by: ray chen <raychen@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
0055aa5f95
commit
b5ae8c9d8a
@ -2,6 +2,7 @@
|
||||
# is used when this pipeline is going to be generating and publishing daily dev builds.
|
||||
parameters:
|
||||
ServiceDirectory: ''
|
||||
Artifacts: []
|
||||
Condition: succeeded()
|
||||
steps:
|
||||
- ${{if ne(parameters.ServiceDirectory, '')}}:
|
||||
@ -11,6 +12,7 @@ steps:
|
||||
arguments: >
|
||||
-ServiceDirectory ${{parameters.ServiceDirectory}}
|
||||
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
|
||||
-artifactList @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json | Select-Object -ExpandProperty name)
|
||||
pwsh: true
|
||||
workingDirectory: $(Pipeline.Workspace)
|
||||
displayName: Dump Package properties
|
||||
|
||||
@ -30,7 +30,11 @@ package properties JSON file. If the package properties JSON file already
|
||||
exists, read the Version property from the existing package properties JSON file
|
||||
and set that as the Version property for the new output. This has the effect of
|
||||
"adding" a DevVersion property to the file which could be different from the
|
||||
Verison property in that file.
|
||||
Version property in that file.
|
||||
|
||||
.PARAMETER artifactList
|
||||
Optional array of artifact names to filter the package properties. Only packages
|
||||
with artifact names matching entries in this list will be processed.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
@ -39,7 +43,8 @@ Param (
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $outDirectory,
|
||||
[string] $prDiff,
|
||||
[switch] $addDevVersion
|
||||
[switch] $addDevVersion,
|
||||
[array] $artifactList
|
||||
)
|
||||
|
||||
. (Join-Path $PSScriptRoot common.ps1)
|
||||
@ -132,6 +137,38 @@ if (-not (Test-Path -Path $outDirectory))
|
||||
New-Item -ItemType Directory -Force -Path $outDirectory | Out-Null
|
||||
}
|
||||
|
||||
if ($artifactList)
|
||||
{
|
||||
# Filter out null, empty, or whitespace-only entries
|
||||
$filteredArtifacts = @($artifactList | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
|
||||
|
||||
if ($filteredArtifacts.Count -eq 0)
|
||||
{
|
||||
Write-Warning "Artifact list contains no valid entries"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')"
|
||||
$artifactSet = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
|
||||
foreach ($artifact in $filteredArtifacts) {
|
||||
$artifactSet.Add($artifact) | Out-Null
|
||||
}
|
||||
|
||||
# Warn about packages missing ArtifactName property
|
||||
$missingArtifactName = $allPackageProperties | Where-Object { $_.PSObject.Properties.Name -notcontains 'ArtifactName' }
|
||||
foreach ($pkg in $missingArtifactName) {
|
||||
Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering."
|
||||
}
|
||||
$allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) }
|
||||
|
||||
if (!$allPackageProperties)
|
||||
{
|
||||
Write-Error "No packages found matching the provided artifact list"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($pkg in $allPackageProperties)
|
||||
{
|
||||
if ($pkg.Name)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user