Handle missing artifacts without exception (#6103)

Co-authored-by: Scott Beddall <scbedd@microsoft.com>
This commit is contained in:
Azure SDK Bot 2024-10-16 16:22:11 -07:00 committed by GitHub
parent 0fa02513db
commit 417342fd14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,8 +103,11 @@ class PackageProps
$content = Get-Content -Raw -Path $ymlPath | CompatibleConvertFrom-Yaml
if ($content) {
$artifacts = $this.GetValueSafely($content, @("extends", "parameters", "Artifacts"))
$artifactForCurrentPackage = $null
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -or $_["name"] -eq $this.Name }
if ($artifacts) {
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -or $_["name"] -eq $this.Name }
}
if ($artifactForCurrentPackage) {
return [HashTable]$artifactForCurrentPackage