diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index b58a6c910..79b9bb96d 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1016,7 +1016,6 @@ function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $Pipeli return $true } - function Get-LanguageDevOpsName($LanguageShort) { switch ($LanguageShort.ToLower()) @@ -1113,4 +1112,91 @@ function Get-ReleasePlan-Link($releasePlanWorkItemId) return $null } return $workItem["fields"] +} + +function Get-ReleasePlansForCPEXAttestation($releasePlanWorkItemId = $null, $targetServiceTreeId = $null) +{ + $fields = @() + $fields += "Custom.ProductServiceTreeID" + $fields += "Custom.ReleasePlanType" + $fields += "Custom.ProductType" + $fields += "Custom.DataScope" + $fields += "Custom.MgmtScope" + $fields += "Custom.ProductName" + + $fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", " + + $query = "SELECT ${fieldList} FROM WorkItems WHERE [System.WorkItemType] = 'Release Plan'" + + if ($releasePlanWorkItemId){ + $query += " AND [System.Id] = '$releasePlanWorkItemId'" + } else { + $query += " AND [System.State] = 'Finished'" + $query += " AND [Custom.AttestationStatus] IN ('', 'Pending')" + $query += " AND [System.Tags] NOT CONTAINS 'Release Planner App Test'" + $query += " AND [System.Tags] NOT CONTAINS 'Release Planner Test App'" + $query += " AND [System.Tags] NOT CONTAINS 'non-APEX tracking'" + $query += " AND [System.Tags] NOT CONTAINS 'out of scope APEX'" + $query += " AND [System.Tags] NOT CONTAINS 'APEX out of scope'" + $query += " AND [System.Tags] NOT CONTAINS 'validate APEX out of scope'" + $query += " AND [Custom.ProductServiceTreeID] <> ''" + $query += " AND [Custom.ProductLifecycle] <> ''" + $query += " AND [Custom.ProductType] IN ('Feature', 'Offering', 'Sku')" + } + + if ($targetServiceTreeId){ + $query += " AND [Custom.ProductServiceTreeID] = '${targetServiceTreeId}'" + } + + $workItems = Invoke-Query $fields $query + return $workItems +} + +function Get-TriagesForCPEXAttestation($triageWorkItemId = $null, $targetServiceTreeId = $null) +{ + $fields = @() + $fields += "Custom.ProductServiceTreeID" + $fields += "Custom.ProductType" + $fields += "Custom.ProductLifecycle" + $fields += "Custom.DataScope" + $fields += "Custom.MgmtScope" + $fields += "Custom.DataplaneAttestationStatus" + $fields += "Custom.ManagementPlaneAttestationStatus" + $fields += "Custom.ProductName" + + $fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", " + + $query = "SELECT ${fieldList} FROM WorkItems WHERE [System.WorkItemType] = 'Triage'" + + if ($triageWorkItemId){ + $query += " AND [System.Id] = '$triageWorkItemId'" + } else { + $query += " AND ([Custom.DataplaneAttestationStatus] IN ('', 'Pending') OR [Custom.ManagementPlaneAttestationStatus] IN ('', 'Pending'))" + $query += " AND [System.Tags] NOT CONTAINS 'Release Planner App Test'" + $query += " AND [System.Tags] NOT CONTAINS 'Release Planner Test App'" + $query += " AND [System.Tags] NOT CONTAINS 'non-APEX tracking'" + $query += " AND [System.Tags] NOT CONTAINS 'out of scope APEX'" + $query += " AND [System.Tags] NOT CONTAINS 'APEX out of scope'" + $query += " AND [System.Tags] NOT CONTAINS 'validate APEX out of scope'" + $query += " AND [Custom.ProductServiceTreeID] <> ''" + $query += " AND [Custom.ProductLifecycle] <> ''" + $query += " AND [Custom.ProductType] IN ('Feature', 'Offering', 'Sku')" + } + + if ($targetServiceTreeId){ + $query += " AND [Custom.ProductServiceTreeID] = '$targetServiceTreeId'" + } + + $workItems = Invoke-Query $fields $query + return $workItems +} + +function Update-AttestationStatusInWorkItem($workItemId, $fieldName, $status) +{ + $fields = "`"${fieldName}=${status}`"" + + Write-Host "Updating Work Item [$workItemId] with status [$status] for field [$fieldName]." + $workItem = UpdateWorkItem -id $workItemId -fields $fields + Write-Host "Updated attestation status for [$fieldName] in Work Item [$workItemId]" + return $true } \ No newline at end of file