From 4ba0d82f127a961054c83f390895c3116df1b9ed Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 8 Feb 2021 12:45:34 -0800 Subject: [PATCH] Update devops helper script based on changes in azure-sdk repo (#560) - Sync devops helper script changes - Fix issue in SemVer script when using strict mode with Language not set Co-authored-by: Wes Haggard --- .../Helpers/DevOps-WorkItem-Helpers.ps1 | 51 +++++++++++-------- eng/common/scripts/SemVer.ps1 | 10 ++-- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 061134f90..0e0ea7db4 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 = @"