diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 37efd0bd0312..3191a4928a27 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -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 diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 7734f9ec3cba..deccaa553c0e 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -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)