diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 061134f90d9b..0e0ea7db4d3a 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -12,9 +12,9 @@ function Invoke-AzBoardsCmd($subCmd, $parameters, $output = $true) return Invoke-Expression "$azCmdStr" | ConvertFrom-Json -AsHashTable } -function LoginToAzureDevops([string]$devop_pat) +function LoginToAzureDevops([string]$devops_pat) { - if (!$devop_pat) { + if (!$devops_pat) { return } $azCmdStr = "'$devops_pat' | az devops login $($ReleaseDevOpsOrgParameters -join ' ')" @@ -44,7 +44,7 @@ function BuildHashKey() } $parentWorkItems = @{} -function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand = $true) +function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand = $false) { $key = BuildHashKey $serviceName $packageDisplayName if ($key -and $parentWorkItems.ContainsKey($key)) { @@ -73,7 +73,7 @@ function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand = foreach ($wi in $workItems) { $localKey = BuildHashKey $wi.fields["Custom.ServiceName"] $wi.fields["Custom.PackageDisplayName"] if (!$localKey) { continue } - if ($parentWorkItems.ContainsKey($localKey)) { + if ($parentWorkItems.ContainsKey($localKey) -and $parentWorkItems[$localKey].id -ne $wi.id) { Write-Warning "Already found parent [$($parentWorkItems[$localKey].id)] with key [$localKey], using that one instead of [$($wi.id)]." } else { @@ -148,7 +148,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr $query = "SELECT ${fieldList} FROM WorkItems WHERE [Work Item Type] = 'Package'" if (!$includeClosed -and !$lang) { - $query += " AND [State] <> 'No Active Development'" + $query += " AND [State] <> 'No Active Development' AND [PackageTypeNewLibrary] = true" } if ($lang) { $query += " AND [Language] = '${lang}'" @@ -172,7 +172,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version." continue } - if ($packageWorkItems.ContainsKey($localKey)) { + if ($packageWorkItems.ContainsKey($localKey) -and $packageWorkItems[$localKey].id -ne $wi.id) { Write-Warning "Already found package [$($packageWorkItems[$localKey].id)] with key [$localKey], using that one instead of [$($wi.id)]." } else { @@ -344,7 +344,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte if ($title -ne $existingItem.fields["System.Title"]) { $changedField = "System.Title" } if ($changedField) { - Write-Host "At least field $changedField ($($existingItem.fields[$field])) changed so updating." + Write-Host "At least field $changedField ($($existingItem.fields[$changedField])) changed so updating." } $beforeState = $existingItem.fields["System.State"] @@ -356,12 +356,12 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte } $existingItem = ResetWorkItemState $existingItem $beforeState -outputCommand $outputCommand - $newparentItem = FindOrCreatePackageGroupParent $serviceName $pkgDisplayName -outputCommand $outputCommand + $newparentItem = FindOrCreatePackageGroupParent $serviceName $pkgDisplayName -outputCommand $false UpdateWorkItemParent $existingItem $newParentItem -outputCommand $outputCommand return $existingItem } - $parentItem = FindOrCreatePackageGroupParent $serviceName $pkgDisplayName -outputCommand $outputCommand + $parentItem = FindOrCreatePackageGroupParent $serviceName $pkgDisplayName -outputCommand $false $workItem = CreateWorkItem $title "Package" "Release" "Release" $fields $assignedTo $parentItem.id -outputCommand $outputCommand $workItem = ResetWorkItemState $workItem -outputCommand $outputCommand Write-Host "[$($workItem.id)]$lang - $pkgName($verMajorMinor) - Created" @@ -496,7 +496,6 @@ function GetMDVersionValue($versionlist) { $mdVersions = "" $mdFormat = "| {0} | {1} | {2} |`n" - $versionlist | ForEach-Object { $mdVersions += ($mdFormat -f $_.Type, $_.Version, $_.Date) } $htmlVersions = "" $htmlFormat = @" @@ -507,7 +506,11 @@ function GetMDVersionValue($versionlist) "@ - $versionlist | ForEach-Object { $htmlVersions += ($htmlFormat -f $_.Type, $_.Version, $_.Date) } + + foreach ($version in $versionList) { + $mdVersions += ($mdFormat -f $version.Type, $version.Version, $version.Date) + $htmlVersions += ($htmlFormat -f $version.Type, $version.Version, $version.Date) + } $htmlTemplate = @"