diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 0c442a16c7b6..c04bc23428e0 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -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'" @@ -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 @@ -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 } @@ -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" } - if ($title -ne $existingItem.fields["System.Title"]) { $changedField = "System.Title" } if ($changedField) { Write-Host "At least field $changedField ($($existingItem.fields[$changedField])) changed so updating." @@ -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)) { @@ -1280,6 +1286,7 @@ function Update-DevOpsReleaseWorkItem { RepoPath = $packageRepoPath Type = $packageType New = $packageNewLibrary + SpecProjectPath = $specProjectPath }; if (!$plannedDate) { @@ -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 } diff --git a/eng/common/scripts/Package-Properties.ps1 b/eng/common/scripts/Package-Properties.ps1 index 0142017c8468..9185a36d3c92 100644 --- a/eng/common/scripts/Package-Properties.ps1 +++ b/eng/common/scripts/Package-Properties.ps1 @@ -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) } @@ -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() } diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 0db23f276b96..7734f9ec3cba 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -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 diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index 24cfdc85468b..8b89bf90adc3 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -155,7 +155,8 @@ function CreateUpdatePackageWorkItem($pkgInfo) -packageNewLibrary $pkgInfo.IsNewSDK ` -serviceName "unknown" ` -packageDisplayName "unknown" ` - -inRelease $IsReleaseBuild + -inRelease $IsReleaseBuild ` + -specProjectPath $pkgInfo.SpecProjectPath if (-not $result) {