Sync eng/common directory with azure-sdk-tools for PR 11692 (#6769)

* Add CPEX KPI attestation automation

* Update kusto info and remove schedule in pipeline

* Add Actual Kpi Ids and Remove changed date filter

* Rewrite Triage Attestation Logic

* Fix Kusto command and Add stricter work item query

* Add params for testing

* Resolve stash conflict

* Add Error Handling and Email Notifications

---------

Co-authored-by: Summer Warren <summerwarren@microsoft.com>
This commit is contained in:
Azure SDK Bot 2025-10-07 14:48:11 -07:00 committed by GitHub
parent 176e49d722
commit 771c6afaba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}