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.
|
# is used when this pipeline is going to be generating and publishing daily dev builds.
|
||||||
parameters:
|
parameters:
|
||||||
ServiceDirectory: ''
|
ServiceDirectory: ''
|
||||||
|
Artifacts: []
|
||||||
Condition: succeeded()
|
Condition: succeeded()
|
||||||
steps:
|
steps:
|
||||||
- ${{if ne(parameters.ServiceDirectory, '')}}:
|
- ${{if ne(parameters.ServiceDirectory, '')}}:
|
||||||
@ -11,6 +12,7 @@ steps:
|
|||||||
arguments: >
|
arguments: >
|
||||||
-ServiceDirectory ${{parameters.ServiceDirectory}}
|
-ServiceDirectory ${{parameters.ServiceDirectory}}
|
||||||
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
|
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
|
||||||
|
-artifactList @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json | Select-Object -ExpandProperty name)
|
||||||
pwsh: true
|
pwsh: true
|
||||||
workingDirectory: $(Pipeline.Workspace)
|
workingDirectory: $(Pipeline.Workspace)
|
||||||
displayName: Dump Package properties
|
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
|
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
|
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
|
"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()]
|
[CmdletBinding()]
|
||||||
@ -39,7 +43,8 @@ Param (
|
|||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
[string] $outDirectory,
|
[string] $outDirectory,
|
||||||
[string] $prDiff,
|
[string] $prDiff,
|
||||||
[switch] $addDevVersion
|
[switch] $addDevVersion,
|
||||||
|
[array] $artifactList
|
||||||
)
|
)
|
||||||
|
|
||||||
. (Join-Path $PSScriptRoot common.ps1)
|
. (Join-Path $PSScriptRoot common.ps1)
|
||||||
@ -132,6 +137,38 @@ if (-not (Test-Path -Path $outDirectory))
|
|||||||
New-Item -ItemType Directory -Force -Path $outDirectory | Out-Null
|
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)
|
foreach ($pkg in $allPackageProperties)
|
||||||
{
|
{
|
||||||
if ($pkg.Name)
|
if ($pkg.Name)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user