From a18b7c9fd9b9f3132ad826400bfa125174ae497e Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 29 Apr 2021 15:42:32 -0700 Subject: [PATCH] Sync Devops helper scripts from azure-sdk repo (#15089) DevOps helper scripts were updated in azure-sdk repo so syncing those changes into the tools repo so they can be used prepare-release script. Co-authored-by: Wes Haggard --- .../Helpers/DevOps-WorkItem-Helpers.ps1 | 32 ++++++++++-- .../Update-DevOps-Release-WorkItem.ps1 | 51 ++++--------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 5a736ceb4ca4..3897cfa816a9 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -142,6 +142,8 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr $fields += "PackageBetaVersions" $fields += "PackageGAVersion" $fields += "PackagePatchVersions" + $fields += "Generated" + $fields += "RoadmapState" $fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", " $query = "SELECT ${fieldList} FROM WorkItems WHERE [Work Item Type] = 'Package'" @@ -295,13 +297,14 @@ function UpdatePackageWorkItemReleaseState($id, $state, $releaseType, $outputCom return UpdateWorkItem -id $id -state $state -fields $fields -outputCommand $outputCommand } -function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $outputCommand = $false) +function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $allowPrompt = $false, $outputCommand = $false) { $workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand if (!$workItem) { $latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand $assignedTo = "me" + $extraFields = @() if ($latestVersionItem) { Write-Verbose "Copying data from latest matching [$($latestVersionItem.id)] with version $($latestVersionItem.fields["Custom.PackageVersionMajorMinor"])" if ($latestVersionItem.fields["System.AssignedTo"]) { @@ -312,14 +315,33 @@ function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $outputCo if (!$pkg.RepoPath -and $pkg.RepoPath -ne "NA" -and $pkg.fields["Custom.PackageRepoPath"]) { $pkg.RepoPath = $pkg.fields["Custom.PackageRepoPath"] } + + $extraFields += "`"Generated=" + $latestVersionItem.fields["Custom.Generated"] + "`"" + $extraFields += "`"RoadmapState=" + $latestVersionItem.fields["Custom.RoadmapState"] + "`"" + } + + if ($allowPrompt) { + if (!$pkg.DisplayName) { + Write-Host "We need a package display name to be used in various places and it should be consistent across languages for similar packages." + while (($readInput = Read-Host -Prompt "Input the display name") -eq "") { } + $packageInfo.DisplayName = $readInput + } + + if (!$pkg.ServiceName) { + Write-Host "We need a package service name to be used in various places and it should be consistent across languages for similar packages." + while (($readInput = Read-Host -Prompt "Input the service name") -eq "") { } + $packageInfo.ServiceName = $readInput + } } - $workItem = CreateOrUpdatePackageWorkItem $lang $pkg $verMajorMinor -existingItem $null -assignedTo $assignedTo -outputCommand $outputCommand + + + $workItem = CreateOrUpdatePackageWorkItem $lang $pkg $verMajorMinor -existingItem $null -assignedTo $assignedTo -extraFields $extraFields -outputCommand $outputCommand } return $workItem } -function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingItem, $assignedTo = $null, $outputCommand = $true) +function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingItem, $assignedTo = $null, $extraFields = $null, $outputCommand = $true) { if (!$lang -or !$pkg -or !$verMajorMinor) { Write-Host "Cannot create or update because one of lang, pkg or verMajorMinor aren't set. [$lang|$($pkg.Package)|$verMajorMinor]" @@ -343,6 +365,10 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte $fields += "`"ServiceName=${serviceName}`"" $fields += "`"PackageRepoPath=${pkgRepoPath}`"" + if ($extraFields) { + $fields += $extraFields + } + if ($existingItem) { $changedField = $null diff --git a/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 b/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 index 1ac552686774..92f9a41106ad 100644 --- a/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 +++ b/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 @@ -58,51 +58,22 @@ $plannedVersions = @( } ) -$workItem = FindPackageWorkItem -lang $language -packageName $packageName -version $versionMajorMinor -includeClosed $true -outputCommand $false - -if (!$workItem) { - $latestVersionItem = FindLatestPackageWorkItem -lang $language -packageName $packageName -outputCommand $false - $assignedTo = "me" - if ($latestVersionItem) { - Write-Host "Copying data from latest matching [$($latestVersionItem.id)] with version $($latestVersionItem.fields["Custom.PackageVersionMajorMinor"])" - if ($latestVersionItem.fields["System.AssignedTo"]) { - $assignedTo = $latestVersionItem.fields["System.AssignedTo"]["uniqueName"] - } - $packageInfo.DisplayName = $latestVersionItem.fields["Custom.PackageDisplayName"] - $packageInfo.ServiceName = $latestVersionItem.fields["Custom.ServiceName"] - if (!$packageInfo.RepoPath -and $packageInfo.RepoPath -ne "NA" -and $packageInfo.fields["Custom.PackageRepoPath"]) { - $packageInfo.RepoPath = $packageInfo.fields["Custom.PackageRepoPath"] - } - } - - Write-Host "Creating a release work item for a package release with the following properties:" - Write-Host " Lanuage: $language" - Write-Host " Version: $versionMajorMinor" - Write-Host " Package: $packageName" - Write-Host " AssignedTo: $assignedTo" - - if (!$packageInfo.DisplayName) { - Write-Host "We need a package display name to be used in various places and it should be consistent across languages for similar packages." - while (($readInput = Read-Host -Prompt "Input the display name") -eq "") { } - $packageInfo.DisplayName = $readInput - } - Write-Host " PackageDisplayName: $($packageInfo.DisplayName)" - - if (!$packageInfo.ServiceName) { - Write-Host "We need a package service name to be used in various places and it should be consistent across languages for similar packages." - while (($readInput = Read-Host -Prompt "Input the service name") -eq "") { } - $packageInfo.ServiceName = $readInput - } - Write-Host " ServiceName: $($packageInfo.ServiceName)" - Write-Host " PackageType: $packageType" - - $workItem = CreateOrUpdatePackageWorkItem -lang $language -pkg $packageInfo -verMajorMinor $versionMajorMinor -assignedTo $assignedTo -outputCommand $false -} +$workItem = FindOrCreateClonePackageWorkItem $language $packageInfo $versionMajorMinor -allowPrompt $true -outputCommand $false if (!$workItem) { Write-Host "Something failed as we don't have a work-item so exiting." exit 1 } + +Write-Host "Updated or created a release work item for a package release with the following properties:" +Write-Host " Lanuage: $($workItem.fields['Custom.Language'])" +Write-Host " Version: $($workItem.fields['Custom.PackageVersionMajorMinor'])" +Write-Host " Package: $($workItem.fields['Custom.Package'])" +Write-Host " AssignedTo: $($workItem.fields['System.AssignedTo']["uniqueName"])" +Write-Host " PackageDisplayName: $($workItem.fields['Custom.PackageDisplayName'])" +Write-Host " ServiceName: $($workItem.fields['Custom.ServiceName'])" +Write-Host " PackageType: $($workItem.fields['Custom.PackageType'])" +Write-Host "" Write-Host "Marking item [$($workItem.id)]$($workItem.fields['System.Title']) as '$state' for '$releaseType'" $updatedWI = UpdatePackageWorkItemReleaseState -id $workItem.id -state "In Release" -releaseType $releaseType -outputCommand $false $updatedWI = UpdatePackageVersions $workItem -plannedVersions $plannedVersions