Skip to content

Commit fc63551

Browse files
azure-sdksmw-ms
andauthored
Sync eng/common directory with azure-sdk-tools for PR 11692 (#37958)
* 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 <[email protected]>
1 parent 3ec630f commit fc63551

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,6 @@ function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $Pipeli
10161016
return $true
10171017
}
10181018

1019-
10201019
function Get-LanguageDevOpsName($LanguageShort)
10211020
{
10221021
switch ($LanguageShort.ToLower())
@@ -1113,4 +1112,91 @@ function Get-ReleasePlan-Link($releasePlanWorkItemId)
11131112
return $null
11141113
}
11151114
return $workItem["fields"]
1115+
}
1116+
1117+
function Get-ReleasePlansForCPEXAttestation($releasePlanWorkItemId = $null, $targetServiceTreeId = $null)
1118+
{
1119+
$fields = @()
1120+
$fields += "Custom.ProductServiceTreeID"
1121+
$fields += "Custom.ReleasePlanType"
1122+
$fields += "Custom.ProductType"
1123+
$fields += "Custom.DataScope"
1124+
$fields += "Custom.MgmtScope"
1125+
$fields += "Custom.ProductName"
1126+
1127+
$fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", "
1128+
1129+
$query = "SELECT ${fieldList} FROM WorkItems WHERE [System.WorkItemType] = 'Release Plan'"
1130+
1131+
if ($releasePlanWorkItemId){
1132+
$query += " AND [System.Id] = '$releasePlanWorkItemId'"
1133+
} else {
1134+
$query += " AND [System.State] = 'Finished'"
1135+
$query += " AND [Custom.AttestationStatus] IN ('', 'Pending')"
1136+
$query += " AND [System.Tags] NOT CONTAINS 'Release Planner App Test'"
1137+
$query += " AND [System.Tags] NOT CONTAINS 'Release Planner Test App'"
1138+
$query += " AND [System.Tags] NOT CONTAINS 'non-APEX tracking'"
1139+
$query += " AND [System.Tags] NOT CONTAINS 'out of scope APEX'"
1140+
$query += " AND [System.Tags] NOT CONTAINS 'APEX out of scope'"
1141+
$query += " AND [System.Tags] NOT CONTAINS 'validate APEX out of scope'"
1142+
$query += " AND [Custom.ProductServiceTreeID] <> ''"
1143+
$query += " AND [Custom.ProductLifecycle] <> ''"
1144+
$query += " AND [Custom.ProductType] IN ('Feature', 'Offering', 'Sku')"
1145+
}
1146+
1147+
if ($targetServiceTreeId){
1148+
$query += " AND [Custom.ProductServiceTreeID] = '${targetServiceTreeId}'"
1149+
}
1150+
1151+
$workItems = Invoke-Query $fields $query
1152+
return $workItems
1153+
}
1154+
1155+
function Get-TriagesForCPEXAttestation($triageWorkItemId = $null, $targetServiceTreeId = $null)
1156+
{
1157+
$fields = @()
1158+
$fields += "Custom.ProductServiceTreeID"
1159+
$fields += "Custom.ProductType"
1160+
$fields += "Custom.ProductLifecycle"
1161+
$fields += "Custom.DataScope"
1162+
$fields += "Custom.MgmtScope"
1163+
$fields += "Custom.DataplaneAttestationStatus"
1164+
$fields += "Custom.ManagementPlaneAttestationStatus"
1165+
$fields += "Custom.ProductName"
1166+
1167+
$fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", "
1168+
1169+
$query = "SELECT ${fieldList} FROM WorkItems WHERE [System.WorkItemType] = 'Triage'"
1170+
1171+
if ($triageWorkItemId){
1172+
$query += " AND [System.Id] = '$triageWorkItemId'"
1173+
} else {
1174+
$query += " AND ([Custom.DataplaneAttestationStatus] IN ('', 'Pending') OR [Custom.ManagementPlaneAttestationStatus] IN ('', 'Pending'))"
1175+
$query += " AND [System.Tags] NOT CONTAINS 'Release Planner App Test'"
1176+
$query += " AND [System.Tags] NOT CONTAINS 'Release Planner Test App'"
1177+
$query += " AND [System.Tags] NOT CONTAINS 'non-APEX tracking'"
1178+
$query += " AND [System.Tags] NOT CONTAINS 'out of scope APEX'"
1179+
$query += " AND [System.Tags] NOT CONTAINS 'APEX out of scope'"
1180+
$query += " AND [System.Tags] NOT CONTAINS 'validate APEX out of scope'"
1181+
$query += " AND [Custom.ProductServiceTreeID] <> ''"
1182+
$query += " AND [Custom.ProductLifecycle] <> ''"
1183+
$query += " AND [Custom.ProductType] IN ('Feature', 'Offering', 'Sku')"
1184+
}
1185+
1186+
if ($targetServiceTreeId){
1187+
$query += " AND [Custom.ProductServiceTreeID] = '$targetServiceTreeId'"
1188+
}
1189+
1190+
$workItems = Invoke-Query $fields $query
1191+
return $workItems
1192+
}
1193+
1194+
function Update-AttestationStatusInWorkItem($workItemId, $fieldName, $status)
1195+
{
1196+
$fields = "`"${fieldName}=${status}`""
1197+
1198+
Write-Host "Updating Work Item [$workItemId] with status [$status] for field [$fieldName]."
1199+
$workItem = UpdateWorkItem -id $workItemId -fields $fields
1200+
Write-Host "Updated attestation status for [$fieldName] in Work Item [$workItemId]"
1201+
return $true
11161202
}

0 commit comments

Comments
 (0)