-
Notifications
You must be signed in to change notification settings - Fork 223
Use full package name in DevOps work item #13076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f431080
4c09a0c
1aa8a59
aed900d
a6f92f3
49fa8e8
9554e6b
5a2dab5
5431862
b79278d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,14 +139,14 @@ function Invoke-Query($fields, $wiql, $output = $true) | |
| return $workItems | ||
| } | ||
|
|
||
| function BuildHashKeyNoNull() | ||
| function BuildHashKeyFromNonNullArgs() | ||
| { | ||
| $filterNulls = $args | Where-Object { $_ } | ||
| # if we had any nulls then return null | ||
| if (!$filterNulls -or $args.Count -ne $filterNulls.Count) { | ||
| # if we had any non-nulls then return it | ||
| if (!$filterNulls) { | ||
| return $null | ||
| } | ||
| return BuildHashKey $args | ||
| return BuildHashKey @filterNulls | ||
| } | ||
|
|
||
| function BuildHashKey() | ||
|
|
@@ -215,16 +215,17 @@ function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand = | |
| $packageWorkItems = @{} | ||
| $packageWorkItemWithoutKeyFields = @{} | ||
|
|
||
| function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true, $ignoreReleasePlannerTests = $true, $tag = $null) | ||
| function FindLatestPackageWorkItem($lang, $packageName, $groupId = $null, $outputCommand = $true, $ignoreReleasePlannerTests = $true, $tag = $null) | ||
| { | ||
| # Cache all the versions of this package and language work items | ||
| $null = FindPackageWorkItem $lang $packageName -includeClosed $true -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag | ||
| $null = FindPackageWorkItem $lang $packageName -includeClosed $true -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag -groupId $groupId | ||
|
|
||
| $latestWI = $null | ||
| foreach ($wi in $packageWorkItems.Values) | ||
| { | ||
| if ($wi.fields["Custom.Language"] -ne $lang) { continue } | ||
| if ($wi.fields["Custom.Package"] -ne $packageName) { continue } | ||
| if ($groupId -and $wi.fields["Custom.GroupId"] -ne $groupId) { continue } | ||
|
|
||
| if (!$latestWI) { | ||
| $latestWI = $wi | ||
|
|
@@ -238,9 +239,9 @@ function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true, | |
| return $latestWI | ||
| } | ||
|
|
||
| function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null) | ||
| function FindPackageWorkItem($lang, $packageName, $version, $groupId = $null, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null) | ||
| { | ||
| $key = BuildHashKeyNoNull $lang $packageName $version | ||
| $key = BuildHashKeyFromNonNullArgs $lang $packageName $version $groupId | ||
| if ($key -and $packageWorkItems.ContainsKey($key)) { | ||
| return $packageWorkItems[$key] | ||
| } | ||
|
|
@@ -253,6 +254,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr | |
| $fields += "System.Tags" | ||
| $fields += "Custom.Language" | ||
| $fields += "Custom.Package" | ||
| $fields += "Custom.GroupId" | ||
| $fields += "Custom.PackageDisplayName" | ||
| $fields += "System.Title" | ||
| $fields += "Custom.PackageType" | ||
|
|
@@ -282,6 +284,9 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr | |
| if ($packageName) { | ||
| $query += " AND [Package] = '${packageName}'" | ||
| } | ||
| if ($groupId) { | ||
| $query += " AND [GroupId] = '${groupId}'" | ||
| } | ||
| if ($version) { | ||
| $query += " AND [PackageVersionMajorMinor] = '${version}'" | ||
| } | ||
|
|
@@ -295,7 +300,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr | |
|
|
||
| foreach ($wi in $workItems) | ||
| { | ||
| $localKey = BuildHashKeyNoNull $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"] | ||
| $localKey = BuildHashKeyFromNonNullArgs $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"] $wi.fields["Custom.GroupId"] | ||
| if (!$localKey) { | ||
| $packageWorkItemWithoutKeyFields[$wi.id] = $wi | ||
| Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version." | ||
|
|
@@ -461,10 +466,10 @@ function UpdatePackageWorkItemReleaseState($id, $state, $releaseType, $outputCom | |
|
|
||
| function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $allowPrompt = $false, $outputCommand = $false, $relatedId = $null, $tag= $null, $ignoreReleasePlannerTests = $true) | ||
| { | ||
| $workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests | ||
| $workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests -groupId $pkg.GroupId | ||
|
|
||
| if (!$workItem) { | ||
| $latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests | ||
| $latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests -groupId $pkg.GroupId | ||
| $assignedTo = "me" | ||
| $extraFields = @() | ||
| if ($latestVersionItem) { | ||
|
|
@@ -512,6 +517,13 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte | |
| Write-Host "Cannot create or update because one of lang, pkg or verMajorMinor aren't set. [$lang|$($pkg.Package)|$verMajorMinor]" | ||
| return | ||
| } | ||
|
|
||
| # PackageProp object uses Group, while other places use GroupId, such as in work item fields and package csv files. | ||
| $pkgGroupId = if ($pkg.PSObject.Properties.Name -contains "GroupId") { | ||
| $pkg.GroupId | ||
| } else { | ||
| $null | ||
| } | ||
| $pkgName = $pkg.Package | ||
| $pkgDisplayName = $pkg.DisplayName | ||
| $pkgType = $pkg.Type | ||
|
|
@@ -523,6 +535,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte | |
| $fields = @() | ||
| $fields += "`"Language=${lang}`"" | ||
| $fields += "`"Package=${pkgName}`"" | ||
| $fields += "`"GroupId=${pkgGroupId}`"" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we only include this clause if groupId isn't null?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather keeping it updated to the input value even if it's null. |
||
| $fields += "`"PackageDisplayName=${pkgDisplayName}`"" | ||
| $fields += "`"PackageType=${pkgType}`"" | ||
| $fields += "`"PackageTypeNewLibrary=${pkgNewLibrary}`"" | ||
|
|
@@ -540,6 +553,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte | |
|
|
||
| if ($lang -ne $existingItem.fields["Custom.Language"]) { $changedField = "Custom.Language" } | ||
| if ($pkgName -ne $existingItem.fields["Custom.Package"]) { $changedField = "Custom.Package" } | ||
| if ($pkgGroupId -ne $existingItem.fields["Custom.GroupId"]) { $changedField = "Custom.GroupId" } | ||
| if ($verMajorMinor -ne $existingItem.fields["Custom.PackageVersionMajorMinor"]) { $changedField = "Custom.PackageVersionMajorMinor" } | ||
| if ($pkgDisplayName -ne $existingItem.fields["Custom.PackageDisplayName"]) { $changedField = "Custom.PackageDisplayName" } | ||
| if ($pkgType -ne [string]$existingItem.fields["Custom.PackageType"]) { $changedField = "Custom.PackageType" } | ||
|
|
@@ -1029,15 +1043,16 @@ function UpdatePackageVersions($pkgWorkItem, $plannedVersions, $shippedVersions) | |
| function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $PipelineUrl) | ||
| { | ||
| $pkgName = $pkgValidationDetails.Name | ||
| $groupId = $pkgValidationDetails.GroupId | ||
| $versionString = $pkgValidationDetails.Version | ||
|
|
||
| $parsedNewVersion = [AzureEngSemanticVersion]::new($versionString) | ||
| $versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor | ||
| $workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $pkgName -version $versionMajorMinor -includeClosed $true -outputCommand $false | ||
| $workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $pkgName -groupId $groupId -version $versionMajorMinor -includeClosed $true -outputCommand $false | ||
|
|
||
| if (!$workItem) | ||
| { | ||
| Write-Host"No work item found for package [$pkgName]." | ||
| Write-Host "No work item found for package [$pkgName] with groupId [$groupId]." | ||
| return $false | ||
| } | ||
|
|
||
|
|
@@ -1250,6 +1265,7 @@ function Update-DevOpsReleaseWorkItem { | |
| [Parameter(Mandatory=$true)] | ||
| [string]$version, | ||
| [string]$plannedDate, | ||
| [string]$groupId = $null, | ||
| [string]$serviceName = $null, | ||
| [string]$packageDisplayName = $null, | ||
| [string]$packageRepoPath = "NA", | ||
|
|
@@ -1277,6 +1293,7 @@ function Update-DevOpsReleaseWorkItem { | |
|
|
||
| $packageInfo = [PSCustomObject][ordered]@{ | ||
| Package = $packageName | ||
| GroupId = $groupId | ||
| DisplayName = $packageDisplayName | ||
| ServiceName = $serviceName | ||
| RepoPath = $packageRepoPath | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -230,16 +230,30 @@ class PackageProps { | |||||
| # Returns important properties of the package relative to the language repo | ||||||
| # Returns a PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath } | ||||||
| # Note: python is required for parsing python package properties. | ||||||
| # GroupId is optional and is used to filter packages for languages that support group identifiers (e.g., Java). | ||||||
| # When GroupId is provided, the function will match both the package name and the group ID. | ||||||
| function Get-PkgProperties { | ||||||
| Param | ||||||
| ( | ||||||
| [Parameter(Mandatory = $true)] | ||||||
| [string]$PackageName, | ||||||
| [string]$ServiceDirectory | ||||||
| [string]$ServiceDirectory, | ||||||
| [string]$GroupId | ||||||
| ) | ||||||
|
|
||||||
| Write-Host "Get-PkgProperties called with PackageName: [$PackageName], ServiceDirectory: [$ServiceDirectory], GroupId: [$GroupId]" | ||||||
|
|
||||||
| $allPkgProps = Get-AllPkgProperties -ServiceDirectory $ServiceDirectory | ||||||
| $pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName }); | ||||||
|
|
||||||
| if ([string]::IsNullOrEmpty($GroupId)) { | ||||||
| $pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName }); | ||||||
| } | ||||||
| else { | ||||||
| $pkgProps = $allPkgProps.Where({ | ||||||
| ($_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName) -and | ||||||
| ($_.PSObject.Properties.Name -contains "Group" -and $_.Group -eq $GroupId) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind this looks to be a packageprops/info so I guess it would still be Group.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The input object comes from the |
||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| if ($pkgProps.Count -ge 1) { | ||||||
| if ($pkgProps.Count -gt 1) { | ||||||
|
|
@@ -248,7 +262,12 @@ function Get-PkgProperties { | |||||
| return $pkgProps[0] | ||||||
| } | ||||||
|
|
||||||
| LogError "Failed to retrieve Properties for [$PackageName]" | ||||||
| if ([string]::IsNullOrEmpty($GroupId)) { | ||||||
| LogError "Failed to retrieve Properties for [$PackageName]" | ||||||
| } | ||||||
| else { | ||||||
| LogError "Failed to retrieve Properties for [$PackageName] with GroupId [$GroupId]. Ensure the package has a Group property matching the specified GroupId." | ||||||
| } | ||||||
| return $null | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -568,3 +587,25 @@ function Get-PkgPropsForEntireService ($serviceDirectoryPath) { | |||||
|
|
||||||
| return $projectProps | ||||||
| } | ||||||
|
|
||||||
| # Get the full package name based on packageInfo properties | ||||||
| # Returns Group+ArtifactName if Group exists and has a value, otherwise returns Name | ||||||
| # If UseColonSeparator switch is enabled, returns Group:ArtifactName format (colon separator) | ||||||
| function Get-FullPackageName { | ||||||
raych1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| param ( | ||||||
| [Parameter(Mandatory=$true)] | ||||||
| [PSCustomObject]$PackageInfo, | ||||||
| [switch]$UseColonSeparator | ||||||
| ) | ||||||
|
|
||||||
| if ($PackageInfo.PSObject.Members.Name -contains "Group") { | ||||||
| $groupId = $PackageInfo.Group | ||||||
| if ($groupId) { | ||||||
| if ($UseColonSeparator) { | ||||||
| return "${groupId}:$($PackageInfo.Name)" | ||||||
| } | ||||||
| return "${groupId}+$($PackageInfo.Name)" | ||||||
| } | ||||||
| } | ||||||
| return $PackageInfo.Name | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.