Skip to content
23 changes: 21 additions & 2 deletions eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
$fields += "Custom.Generated"
$fields += "Custom.RoadmapState"
$fields += "Microsoft.VSTS.Common.StateChangeDate"
$fields += "Custom.SpecProjectPath"

$fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", "
$query = "SELECT ${fieldList} FROM WorkItems WHERE [Work Item Type] = 'Package'"
Expand Down Expand Up @@ -516,6 +517,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
$pkgType = $pkg.Type
$pkgNewLibrary = $pkg.New
$pkgRepoPath = $pkg.RepoPath
$specProjectPath = $pkg.SpecProjectPath
$serviceName = $pkg.ServiceName
$title = $lang + " - " + $pkg.DisplayName + " - " + $verMajorMinor

Expand All @@ -529,6 +531,10 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
$fields += "`"ServiceName=${serviceName}`""
$fields += "`"PackageRepoPath=${pkgRepoPath}`""

if ($specProjectPath) {
$fields += "`"Custom.SpecProjectPath=${specProjectPath}`""
}

if ($extraFields) {
$fields += $extraFields
}
Expand All @@ -545,7 +551,6 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
if ($pkgNewLibrary -ne $existingItem.fields["Custom.PackageTypeNewLibrary"]) { $changedField = "Custom.PackageTypeNewLibrary" }
if ($pkgRepoPath -ne $existingItem.fields["Custom.PackageRepoPath"]) { $changedField = "Custom.PackageRepoPath" }
if ($serviceName -ne $existingItem.fields["Custom.ServiceName"]) { $changedField = "Custom.ServiceName" }
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removed check for title changes could mask important updates. If the title changes, the work item should be updated to reflect the new title. Consider adding back the title check or document why title changes should not trigger updates.

Copilot uses AI. Check for mistakes.
if ($title -ne $existingItem.fields["System.Title"]) { $changedField = "System.Title" }

if ($changedField) {
Write-Host "At least field $changedField ($($existingItem.fields[$changedField])) changed so updating."
Expand Down Expand Up @@ -1256,7 +1261,8 @@ function Update-DevOpsReleaseWorkItem {
[string]$packageNewLibrary = "true",
[string]$relatedWorkItemId = $null,
[string]$tag = $null,
[bool]$inRelease = $true
[bool]$inRelease = $true,
[string]$specProjectPath = ""
)

if (!(Get-Command az -ErrorAction SilentlyContinue)) {
Expand All @@ -1280,6 +1286,7 @@ function Update-DevOpsReleaseWorkItem {
RepoPath = $packageRepoPath
Type = $packageType
New = $packageNewLibrary
SpecProjectPath = $specProjectPath
};

if (!$plannedDate) {
Expand Down Expand Up @@ -1326,6 +1333,18 @@ function Update-DevOpsReleaseWorkItem {
}
$updatedWI = UpdatePackageVersions $workItem -plannedVersions $plannedVersions



if ((!$workItem.fields.ContainsKey('Custom.SpecProjectPath') -and $packageInfo.SpecProjectPath) -or
($workItem.fields.ContainsKey('Custom.SpecProjectPath') -and ($workItem.fields['Custom.SpecProjectPath'] -ne $packageInfo.SpecProjectPath))
) {
Write-Host "Updating SpecProjectPath to '$($packageInfo.SpecProjectPath)' for work item [$($workItem.id)]"
UpdateWorkItem `
-id $workItem.id `
-fields "`"Custom.SpecProjectPath=$($packageInfo.SpecProjectPath)`"" `
-outputCommand $false
}

Write-Host "Release tracking item is at https://dev.azure.com/azure-sdk/Release/_workitems/edit/$($updatedWI.id)/"
return $true
}
8 changes: 8 additions & 0 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class PackageProps {
[HashTable]$ArtifactDetails
[HashTable]$CIParameters

# Path from root of azure-rest-api-specs repo to spec project (read from
# tsp-location.yaml if it exists in the package directory)
[string]$SpecProjectPath

PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) {
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
}
Expand Down Expand Up @@ -61,6 +65,10 @@ class PackageProps {
$this.ChangeLogPath = $null
}

if (Test-Path (Join-Path $directoryPath 'tsp-location.yaml')) {
$this.SpecProjectPath = (LoadFrom-Yaml (Join-Path $directoryPath 'tsp-location.yaml')).directory
}

$this.CIParameters = @{"CIMatrixConfigs" = @()}
$this.InitializeCIArtifacts()
}
Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ foreach ($pkg in $allPackageProperties)
if (-not [System.String]::IsNullOrEmpty($pkg.Group)) {
Write-Host "GroupId: $($pkg.Group)"
}
Write-Host "Spec Project Path: $($pkg.SpecProjectPath)"
Write-Host "Release date: $($pkg.ReleaseStatus)"
$configFilePrefix = $pkg.Name

Expand Down
3 changes: 2 additions & 1 deletion eng/common/scripts/Validate-All-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ function CreateUpdatePackageWorkItem($pkgInfo)
-packageNewLibrary $pkgInfo.IsNewSDK `
-serviceName "unknown" `
-packageDisplayName "unknown" `
-inRelease $IsReleaseBuild
-inRelease $IsReleaseBuild `
-specProjectPath $pkgInfo.SpecProjectPath

if (-not $result)
{
Expand Down
Loading