Skip to content

Commit 9b399ac

Browse files
Set product as parent of package work item. (Azure#37098)
Co-authored-by: praveenkuttappan <prmarott@microsoft.com>
1 parent 4a57c41 commit 9b399ac

File tree

1 file changed

+2
-75
lines changed

1 file changed

+2
-75
lines changed

eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -182,56 +182,6 @@ function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand =
182182
return $null
183183
}
184184

185-
$releasePlanWorkItems = @{}
186-
function FindReleasePlanWorkItem($serviceName, $packageDisplayName, $outputCommand = $false, $ignoreReleasePlannerTests = $true)
187-
{
188-
$key = BuildHashKey $serviceName $packageDisplayName
189-
if ($key -and $releasePlanWorkItems.ContainsKey($key)) {
190-
return $releasePlanWorkItems[$key]
191-
}
192-
193-
if ($serviceName) {
194-
$condition = "[ServiceName] = '${serviceName}'"
195-
if ($packageDisplayName) {
196-
$condition += " AND [PackageDisplayName] = '${packageDisplayName}'"
197-
}
198-
else {
199-
$condition += " AND [PackageDisplayName] = ''"
200-
}
201-
}
202-
else {
203-
$condition = "[ServiceName] <> ''"
204-
}
205-
$condition += " AND [System.State] <> 'Finished'"
206-
if($ignoreReleasePlannerTests){
207-
$condition += " AND [Tags] NOT CONTAINS 'Release Planner App Test'"
208-
}
209-
210-
$query = "SELECT [ID], [ServiceName], [PackageDisplayName], [Parent] FROM WorkItems WHERE [Work Item Type] = 'Release Plan' AND ${condition}"
211-
212-
$fields = @("System.Id", "Custom.ServiceName", "Custom.PackageDisplayName", "System.Parent", "System.Tags")
213-
214-
$workItems = Invoke-Query $fields $query $outputCommand
215-
216-
foreach ($wi in $workItems)
217-
{
218-
$localKey = BuildHashKey $wi.fields["Custom.ServiceName"] $wi.fields["Custom.PackageDisplayName"]
219-
if (!$localKey) { continue }
220-
if ($releasePlanWorkItems.ContainsKey($localKey) -and $releasePlanWorkItems[$localKey].id -ne $wi.id) {
221-
Write-Warning "Already found parent [$($releasePlanWorkItems[$localKey].id)] with key [$localKey], using that one instead of [$($wi.id)]."
222-
}
223-
else {
224-
Write-Verbose "[$($wi.id)]$localKey - Cached"
225-
$releasePlanWorkItems[$localKey] = $wi
226-
}
227-
}
228-
229-
if ($key -and $releasePlanWorkItems.ContainsKey($key)) {
230-
return $releasePlanWorkItems[$key]
231-
}
232-
return $null
233-
}
234-
235185
$packageWorkItems = @{}
236186
$packageWorkItemWithoutKeyFields = @{}
237187

@@ -545,40 +495,17 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
545495
}
546496
}
547497

548-
$newparentItem = FindOrCreateReleasePlanParent $serviceName $pkgDisplayName -outputCommand $false
498+
$newparentItem = FindOrCreatePackageGroupParent $serviceName $pkgDisplayName -outputCommand $false
549499
UpdateWorkItemParent $existingItem $newParentItem -outputCommand $outputCommand
550500
return $existingItem
551501
}
552502

553-
$parentItem = FindOrCreateReleasePlanParent $serviceName $pkgDisplayName -outputCommand $false
503+
$parentItem = FindOrCreatePackageGroupParent $serviceName $pkgDisplayName -outputCommand $false
554504
$workItem = CreateWorkItem $title "Package" "Release" "Release" $fields $assignedTo $parentItem.id -outputCommand $outputCommand
555505
Write-Host "[$($workItem.id)]$lang - $pkgName($verMajorMinor) - Created"
556506
return $workItem
557507
}
558508

559-
function FindOrCreateReleasePlanParent($serviceName, $packageDisplayName, $outputCommand = $true, $ignoreReleasePlannerTests = $true)
560-
{
561-
$existingItem = FindReleasePlanWorkItem $serviceName $packageDisplayName -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests
562-
if ($existingItem) {
563-
Write-Host "Found existing release plan work item [$($existingItem.id)]"
564-
$newparentItem = FindOrCreatePackageGroupParent $serviceName $packageDisplayName -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests
565-
UpdateWorkItemParent $existingItem $newParentItem
566-
return $existingItem
567-
}
568-
569-
$fields = @()
570-
$fields += "`"PackageDisplayName=${packageDisplayName}`""
571-
$fields += "`"ServiceName=${serviceName}`""
572-
$productParentItem = FindOrCreatePackageGroupParent $serviceName $packageDisplayName -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests
573-
$title = "Release Plan - $($packageDisplayName)"
574-
$workItem = CreateWorkItem $title "Release Plan" "Release" "Release" $fields $null $productParentItem.id
575-
576-
$localKey = BuildHashKey $serviceName $packageDisplayName
577-
Write-Host "[$($workItem.id)]$localKey - Created release plan work item"
578-
$releasePlanWorkItems[$localKey] = $workItem
579-
return $workItem
580-
}
581-
582509
function FindOrCreatePackageGroupParent($serviceName, $packageDisplayName, $outputCommand = $true, $ignoreReleasePlannerTests = $true)
583510
{
584511
$existingItem = FindParentWorkItem $serviceName $packageDisplayName -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests

0 commit comments

Comments
 (0)