Updated script to process groupId in work items
This commit is contained in:
parent
e10992a7d4
commit
13d95d3a46
@ -215,16 +215,17 @@ function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand =
|
|||||||
$packageWorkItems = @{}
|
$packageWorkItems = @{}
|
||||||
$packageWorkItemWithoutKeyFields = @{}
|
$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
|
# 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
|
$latestWI = $null
|
||||||
foreach ($wi in $packageWorkItems.Values)
|
foreach ($wi in $packageWorkItems.Values)
|
||||||
{
|
{
|
||||||
if ($wi.fields["Custom.Language"] -ne $lang) { continue }
|
if ($wi.fields["Custom.Language"] -ne $lang) { continue }
|
||||||
if ($wi.fields["Custom.Package"] -ne $packageName) { continue }
|
if ($wi.fields["Custom.Package"] -ne $packageName) { continue }
|
||||||
|
if ($groupId -and $wi.fields["Custom.Group"] -ne $groupId) { continue }
|
||||||
|
|
||||||
if (!$latestWI) {
|
if (!$latestWI) {
|
||||||
$latestWI = $wi
|
$latestWI = $wi
|
||||||
@ -238,9 +239,13 @@ function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true,
|
|||||||
return $latestWI
|
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
|
$keyArgs = @($lang, $packageName, $version)
|
||||||
|
if (![string]::IsNullOrWhiteSpace($groupId)) {
|
||||||
|
$keyArgs += $groupId
|
||||||
|
}
|
||||||
|
$key = BuildHashKeyNoNull @keyArgs
|
||||||
if ($key -and $packageWorkItems.ContainsKey($key)) {
|
if ($key -and $packageWorkItems.ContainsKey($key)) {
|
||||||
return $packageWorkItems[$key]
|
return $packageWorkItems[$key]
|
||||||
}
|
}
|
||||||
@ -253,6 +258,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
|
|||||||
$fields += "System.Tags"
|
$fields += "System.Tags"
|
||||||
$fields += "Custom.Language"
|
$fields += "Custom.Language"
|
||||||
$fields += "Custom.Package"
|
$fields += "Custom.Package"
|
||||||
|
$fields += "Custom.Group"
|
||||||
$fields += "Custom.PackageDisplayName"
|
$fields += "Custom.PackageDisplayName"
|
||||||
$fields += "System.Title"
|
$fields += "System.Title"
|
||||||
$fields += "Custom.PackageType"
|
$fields += "Custom.PackageType"
|
||||||
@ -282,6 +288,9 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
|
|||||||
if ($packageName) {
|
if ($packageName) {
|
||||||
$query += " AND [Package] = '${packageName}'"
|
$query += " AND [Package] = '${packageName}'"
|
||||||
}
|
}
|
||||||
|
if ($groupId) {
|
||||||
|
$query += " AND [Group] = '${groupId}'"
|
||||||
|
}
|
||||||
if ($version) {
|
if ($version) {
|
||||||
$query += " AND [PackageVersionMajorMinor] = '${version}'"
|
$query += " AND [PackageVersionMajorMinor] = '${version}'"
|
||||||
}
|
}
|
||||||
@ -295,7 +304,11 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
|
|||||||
|
|
||||||
foreach ($wi in $workItems)
|
foreach ($wi in $workItems)
|
||||||
{
|
{
|
||||||
$localKey = BuildHashKeyNoNull $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"]
|
$localKeyArgs = @($wi.fields["Custom.Language"], $wi.fields["Custom.Package"], $wi.fields["Custom.PackageVersionMajorMinor"])
|
||||||
|
if (![string]::IsNullOrWhiteSpace($wi.fields["Custom.Group"])) {
|
||||||
|
$localKeyArgs += $wi.fields["Custom.Group"]
|
||||||
|
}
|
||||||
|
$localKey = BuildHashKeyNoNull @localKeyArgs
|
||||||
if (!$localKey) {
|
if (!$localKey) {
|
||||||
$packageWorkItemWithoutKeyFields[$wi.id] = $wi
|
$packageWorkItemWithoutKeyFields[$wi.id] = $wi
|
||||||
Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version."
|
Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version."
|
||||||
@ -461,10 +474,10 @@ function UpdatePackageWorkItemReleaseState($id, $state, $releaseType, $outputCom
|
|||||||
|
|
||||||
function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $allowPrompt = $false, $outputCommand = $false, $relatedId = $null, $tag= $null, $ignoreReleasePlannerTests = $true)
|
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.Group
|
||||||
|
|
||||||
if (!$workItem) {
|
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.Group
|
||||||
$assignedTo = "me"
|
$assignedTo = "me"
|
||||||
$extraFields = @()
|
$extraFields = @()
|
||||||
if ($latestVersionItem) {
|
if ($latestVersionItem) {
|
||||||
@ -513,6 +526,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
$pkgName = $pkg.Package
|
$pkgName = $pkg.Package
|
||||||
|
$pkgGroupId = if ($pkg.PSObject.Properties.Name -contains "GroupId") { $pkg.GroupId } else { $pkg.Group }
|
||||||
$pkgDisplayName = $pkg.DisplayName
|
$pkgDisplayName = $pkg.DisplayName
|
||||||
$pkgType = $pkg.Type
|
$pkgType = $pkg.Type
|
||||||
$pkgNewLibrary = $pkg.New
|
$pkgNewLibrary = $pkg.New
|
||||||
@ -523,6 +537,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
|
|||||||
$fields = @()
|
$fields = @()
|
||||||
$fields += "`"Language=${lang}`""
|
$fields += "`"Language=${lang}`""
|
||||||
$fields += "`"Package=${pkgName}`""
|
$fields += "`"Package=${pkgName}`""
|
||||||
|
$fields += "`"Group=${pkgGroupId}`""
|
||||||
$fields += "`"PackageDisplayName=${pkgDisplayName}`""
|
$fields += "`"PackageDisplayName=${pkgDisplayName}`""
|
||||||
$fields += "`"PackageType=${pkgType}`""
|
$fields += "`"PackageType=${pkgType}`""
|
||||||
$fields += "`"PackageTypeNewLibrary=${pkgNewLibrary}`""
|
$fields += "`"PackageTypeNewLibrary=${pkgNewLibrary}`""
|
||||||
@ -540,6 +555,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
|
|||||||
|
|
||||||
if ($lang -ne $existingItem.fields["Custom.Language"]) { $changedField = "Custom.Language" }
|
if ($lang -ne $existingItem.fields["Custom.Language"]) { $changedField = "Custom.Language" }
|
||||||
if ($pkgName -ne $existingItem.fields["Custom.Package"]) { $changedField = "Custom.Package" }
|
if ($pkgName -ne $existingItem.fields["Custom.Package"]) { $changedField = "Custom.Package" }
|
||||||
|
if ($pkgGroupId -ne $existingItem.fields["Custom.Group"]) { $changedField = "Custom.Group" }
|
||||||
if ($verMajorMinor -ne $existingItem.fields["Custom.PackageVersionMajorMinor"]) { $changedField = "Custom.PackageVersionMajorMinor" }
|
if ($verMajorMinor -ne $existingItem.fields["Custom.PackageVersionMajorMinor"]) { $changedField = "Custom.PackageVersionMajorMinor" }
|
||||||
if ($pkgDisplayName -ne $existingItem.fields["Custom.PackageDisplayName"]) { $changedField = "Custom.PackageDisplayName" }
|
if ($pkgDisplayName -ne $existingItem.fields["Custom.PackageDisplayName"]) { $changedField = "Custom.PackageDisplayName" }
|
||||||
if ($pkgType -ne [string]$existingItem.fields["Custom.PackageType"]) { $changedField = "Custom.PackageType" }
|
if ($pkgType -ne [string]$existingItem.fields["Custom.PackageType"]) { $changedField = "Custom.PackageType" }
|
||||||
@ -1029,15 +1045,16 @@ function UpdatePackageVersions($pkgWorkItem, $plannedVersions, $shippedVersions)
|
|||||||
function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $PipelineUrl)
|
function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $PipelineUrl)
|
||||||
{
|
{
|
||||||
$pkgName = $pkgValidationDetails.Name
|
$pkgName = $pkgValidationDetails.Name
|
||||||
|
$groupId = $pkgValidationDetails.Group
|
||||||
$versionString = $pkgValidationDetails.Version
|
$versionString = $pkgValidationDetails.Version
|
||||||
|
|
||||||
$parsedNewVersion = [AzureEngSemanticVersion]::new($versionString)
|
$parsedNewVersion = [AzureEngSemanticVersion]::new($versionString)
|
||||||
$versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor
|
$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)
|
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
|
return $false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1250,6 +1267,7 @@ function Update-DevOpsReleaseWorkItem {
|
|||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$version,
|
[string]$version,
|
||||||
[string]$plannedDate,
|
[string]$plannedDate,
|
||||||
|
[string]$groupId = $null,
|
||||||
[string]$serviceName = $null,
|
[string]$serviceName = $null,
|
||||||
[string]$packageDisplayName = $null,
|
[string]$packageDisplayName = $null,
|
||||||
[string]$packageRepoPath = "NA",
|
[string]$packageRepoPath = "NA",
|
||||||
@ -1277,6 +1295,7 @@ function Update-DevOpsReleaseWorkItem {
|
|||||||
|
|
||||||
$packageInfo = [PSCustomObject][ordered]@{
|
$packageInfo = [PSCustomObject][ordered]@{
|
||||||
Package = $packageName
|
Package = $packageName
|
||||||
|
Group = $groupId
|
||||||
DisplayName = $packageDisplayName
|
DisplayName = $packageDisplayName
|
||||||
ServiceName = $serviceName
|
ServiceName = $serviceName
|
||||||
RepoPath = $packageRepoPath
|
RepoPath = $packageRepoPath
|
||||||
|
|||||||
@ -158,10 +158,9 @@ if ($null -eq $newVersionParsed)
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$fullPackageName = Get-FullPackageName -PackageInfo $packageProperties
|
|
||||||
|
|
||||||
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
|
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
|
||||||
-packageName $fullPackageName `
|
-packageName $packageProperties.Name `
|
||||||
|
-groupId $packageProperties.Group `
|
||||||
-version $newVersion `
|
-version $newVersion `
|
||||||
-plannedDate $releaseDateString `
|
-plannedDate $releaseDateString `
|
||||||
-packageRepoPath $packageProperties.serviceDirectory `
|
-packageRepoPath $packageProperties.serviceDirectory `
|
||||||
|
|||||||
@ -111,13 +111,13 @@ function VerifyAPIReview($packageName, $packageVersion, $language)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function IsVersionShipped($packageName, $packageVersion)
|
function IsVersionShipped($packageName, $packageVersion, $groupId = $null)
|
||||||
{
|
{
|
||||||
# This function will decide if a package version is already shipped or not
|
# This function will decide if a package version is already shipped or not
|
||||||
Write-Host "Checking if a version is already shipped for package $packageName with version $packageVersion."
|
Write-Host "Checking if a version is already shipped for package $packageName with version $packageVersion."
|
||||||
$parsedNewVersion = [AzureEngSemanticVersion]::new($packageVersion)
|
$parsedNewVersion = [AzureEngSemanticVersion]::new($packageVersion)
|
||||||
$versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor
|
$versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor
|
||||||
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $packageName -version $versionMajorMinor -includeClosed $true -outputCommand $false
|
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $packageName -groupId $groupId -version $versionMajorMinor -includeClosed $true -outputCommand $false
|
||||||
if ($workItem)
|
if ($workItem)
|
||||||
{
|
{
|
||||||
# Check if the package version is already shipped
|
# Check if the package version is already shipped
|
||||||
@ -127,7 +127,7 @@ function IsVersionShipped($packageName, $packageVersion)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "No work item found for package [$packageName]. Creating new work item for package."
|
Write-Host "No work item found for package [$packageName], group [$groupId]. Creating new work item for package."
|
||||||
}
|
}
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
@ -135,8 +135,8 @@ function IsVersionShipped($packageName, $packageVersion)
|
|||||||
function CreateUpdatePackageWorkItem($pkgInfo)
|
function CreateUpdatePackageWorkItem($pkgInfo)
|
||||||
{
|
{
|
||||||
# This function will create or update package work item in Azure DevOps
|
# This function will create or update package work item in Azure DevOps
|
||||||
$fullPkgNameInRemoteFeed = Get-FullPackageName -PackageInfo $pkgInfo
|
|
||||||
$versionString = $pkgInfo.Version
|
$versionString = $pkgInfo.Version
|
||||||
|
$packageName = $pkgInfo.Name
|
||||||
$plannedDate = $pkgInfo.ReleaseStatus
|
$plannedDate = $pkgInfo.ReleaseStatus
|
||||||
$setReleaseState = $true
|
$setReleaseState = $true
|
||||||
if (!$plannedDate -or $plannedDate -eq "Unreleased")
|
if (!$plannedDate -or $plannedDate -eq "Unreleased")
|
||||||
@ -147,7 +147,8 @@ function CreateUpdatePackageWorkItem($pkgInfo)
|
|||||||
|
|
||||||
# Create or update package work item
|
# Create or update package work item
|
||||||
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
|
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
|
||||||
-packageName $fullPkgNameInRemoteFeed `
|
-packageName $packageName `
|
||||||
|
-groupId $pkgInfo.Group `
|
||||||
-version $versionString `
|
-version $versionString `
|
||||||
-plannedDate $plannedDate `
|
-plannedDate $plannedDate `
|
||||||
-packageRepoPath $pkgInfo.serviceDirectory `
|
-packageRepoPath $pkgInfo.serviceDirectory `
|
||||||
@ -175,19 +176,14 @@ function ProcessPackage($packageInfo)
|
|||||||
$pkgName = $packageInfo.Name
|
$pkgName = $packageInfo.Name
|
||||||
$changeLogPath = $packageInfo.ChangeLogPath
|
$changeLogPath = $packageInfo.ChangeLogPath
|
||||||
$versionString = $packageInfo.Version
|
$versionString = $packageInfo.Version
|
||||||
Write-Host "Checking if we need to create or update work item for package $pkgName with version $versionString."
|
Write-Host "Checking if we need to create or update work item for package $pkgName and groupId $packageInfo.Group with version $versionString."
|
||||||
|
|
||||||
# If there's a groupId that means this is Java and pkgName = GroupId+ArtifactName
|
|
||||||
Write-Host "Package name before checking groupId: $pkgName"
|
Write-Host "Package name before checking groupId: $pkgName"
|
||||||
$fullPkgNameInRemoteFeed = Get-FullPackageName -PackageInfo $packageInfo
|
$isShipped = IsVersionShipped $pkgName $versionString $packageInfo.Group
|
||||||
$isShipped = IsVersionShipped $fullPkgNameInRemoteFeed $versionString
|
|
||||||
if ($isShipped) {
|
if ($isShipped) {
|
||||||
Write-Host "Package work item already exists for version [$versionString] that is marked as shipped. Skipping the update of package work item."
|
Write-Host "Package work item already exists for version [$versionString] that is marked as shipped. Skipping the update of package work item."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Validating package $fullPkgNameInRemoteFeed with version $versionString."
|
|
||||||
|
|
||||||
# Change log validation
|
# Change log validation
|
||||||
$changeLogStatus = [PSCustomObject]@{
|
$changeLogStatus = [PSCustomObject]@{
|
||||||
Name = "Change Log Validation"
|
Name = "Change Log Validation"
|
||||||
@ -207,8 +203,10 @@ function ProcessPackage($packageInfo)
|
|||||||
Write-Host "Checking API review status for package $fullPackageName"
|
Write-Host "Checking API review status for package $fullPackageName"
|
||||||
$apireviewDetails = VerifyAPIReview $fullPackageName $packageInfo.Version $Language
|
$apireviewDetails = VerifyAPIReview $fullPackageName $packageInfo.Version $Language
|
||||||
|
|
||||||
|
# The following object will be used to update package work item, the name should be package name only without groupId
|
||||||
$pkgValidationDetails= [PSCustomObject]@{
|
$pkgValidationDetails= [PSCustomObject]@{
|
||||||
Name = $fullPkgNameInRemoteFeed
|
Name = $pkgName
|
||||||
|
Group = $packageInfo.Group
|
||||||
Version = $packageInfo.Version
|
Version = $packageInfo.Version
|
||||||
ChangeLogValidation = $changeLogStatus
|
ChangeLogValidation = $changeLogStatus
|
||||||
APIReviewValidation = $apireviewDetails.ApiviewApproval
|
APIReviewValidation = $apireviewDetails.ApiviewApproval
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user