From ffe34c6309de228c96e4448384d13d054f3f22cc Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Thu, 4 Sep 2025 18:46:38 -0400 Subject: [PATCH 1/5] Add a script to update pull request URL in release plan from SDK generation pipeline --- .../Helpers/DevOps-WorkItem-Helpers.ps1 | 18 ++++++++++ .../Update-PullRequest-In-ReleasePlan.ps1 | 34 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 9bf29a72bde6..76d3c7a40d07 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1073,4 +1073,22 @@ function Update-ReleaseStatusInReleasePlan($releasePlanWorkItemId, $status, $ver Write-Host "Updating Release Plan [$releasePlanWorkItemId] with status [$status] for language [$LanguageShort]." $workItem = UpdateWorkItem -id $releasePlanWorkItemId -fields $fields Write-Host "Updated release status for [$LanguageShort] in Release Plan [$releasePlanWorkItemId]" +} + +function Update-PullRequestInReleasePlan($releasePlanWorkItemId, $pullRequestUrl, $status, $languageName) +{ + $devopsFieldLanguage = Get-LanguageDevOpsName -LanguageShort $languageName + if (!$devopsFieldLanguage) + { + Write-Host "Unsupported language to update release plan, language [$languageName]" + return $null + } + + $fields = @() + $fields += "`"SDKPullRequestFor$($devopsFieldLanguage)=$pullRequestUrl`"" + $fields += "`"SDKPullRequestStatusFor$($devopsFieldLanguage)=$status`"" + + Write-Host "Updating Release Plan [$releasePlanWorkItemId] with Pull Request URL for language [$languageName]." + $workItem = UpdateWorkItem -id $releasePlanWorkItemId -fields $fields + Write-Host "Updated Pull Request URL [$pullRequestUrl] for [$languageName] in Release Plan [$releasePlanWorkItemId]" } \ No newline at end of file diff --git a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 new file mode 100644 index 000000000000..167328ac11b6 --- /dev/null +++ b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 @@ -0,0 +1,34 @@ +param( + [Parameter(Mandatory = $true)] + $ReleasePlanWorkItemId, + [Parameter(Mandatory = $true)] + $PullRequestUrl, + [Parameter(Mandatory = $true)] + $Status, + [Parameter(Mandatory = $true)] + $LanguageName +) + +<# +.SYNOPSIS +Updates the pull request URL and status in the specified release plan work item for a given programming language. + +.PARAMETER ReleasePlanWorkItemId +The ID of the release plan work item to update. + +.PARAMETER PullRequestUrl +The URL of the pull request to set in the release plan. + +.PARAMETER Status +The status of the pull request. + +.PARAMETER Language +The programming language associated with the pull request. + +#> + +Set-StrictMode -Version 3 +. (Join-Path $PSScriptRoot common.ps1) +. (Join-Path $PSScriptRoot Helpers DevOps-WorkItem-Helpers.ps1) + +Update-PullRequestInReleasePlan $ReleasePlanWorkItemId $PullRequestUrl $Status $LanguageName \ No newline at end of file From f5a18da62471e75134585f9c62e0ef711e850aed Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Thu, 4 Sep 2025 19:59:56 -0400 Subject: [PATCH 2/5] Add steps to create a comment in SDK pr about release plan --- .../Helpers/DevOps-WorkItem-Helpers.ps1 | 14 ++++++ .../Update-PullRequest-In-ReleasePlan.ps1 | 46 +++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 76d3c7a40d07..3f37d4bbb060 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1091,4 +1091,18 @@ function Update-PullRequestInReleasePlan($releasePlanWorkItemId, $pullRequestUrl Write-Host "Updating Release Plan [$releasePlanWorkItemId] with Pull Request URL for language [$languageName]." $workItem = UpdateWorkItem -id $releasePlanWorkItemId -fields $fields Write-Host "Updated Pull Request URL [$pullRequestUrl] for [$languageName] in Release Plan [$releasePlanWorkItemId]" +} + +function Get-ReleasePlan-Link($releasePlanWorkItemId) +{ + $fields = @() + $fields += "System.Id" + $fields += "System.Title" + $fields += "Custom.ReleasePlanLink" + $fields += "Custom.ReleasePlanSubmittedby" + + $fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", " + $query = "SELECT ${fieldList} FROM WorkItems WHERE [System.Id] = $releasePlanWorkItemId" + $workItem = Invoke-Query $fields $query + return $workItem["fields"] } \ No newline at end of file diff --git a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 index 167328ac11b6..ed7e929733ee 100644 --- a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 +++ b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 @@ -6,7 +6,9 @@ param( [Parameter(Mandatory = $true)] $Status, [Parameter(Mandatory = $true)] - $LanguageName + $LanguageName, + [Parameter(Mandatory = $true)] + $AuthToken ) <# @@ -22,13 +24,51 @@ The URL of the pull request to set in the release plan. .PARAMETER Status The status of the pull request. -.PARAMETER Language +.PARAMETER LanguageName The programming language associated with the pull request. +.PARAMETER AuthToken +The authentication token for GitHub API. + #> Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) . (Join-Path $PSScriptRoot Helpers DevOps-WorkItem-Helpers.ps1) -Update-PullRequestInReleasePlan $ReleasePlanWorkItemId $PullRequestUrl $Status $LanguageName \ No newline at end of file +$releasePlan = Get-ReleasePlan-Link $ReleasePlanWorkItemId +if (!$releasePlan) +{ + LogError "Release plan with ID $ReleasePlanWorkItemId not found." +} + +LogDebug "Updating pull request in release plan" +Update-PullRequestInReleasePlan $ReleasePlanWorkItemId $PullRequestUrl $Status $LanguageName + +$releasePlanLink = $releasePlan["Custom.ReleasePlanLink"] +$releasePlanSubmittedBy = $releasePlan["Custom.ReleasePlanSubmittedby"] +$ReleasePlanTitle = $releasePlan["System.Title"] +LogDebug "Release plan title: $ReleasePlanTitle" +LogDebug "Release plan link: $releasePlanLink" +Write-Host "Submitted by: $releasePlanSubmittedBy" + +# Add a comment in pull request to provide release plan context +$regex = [regex]::new("https://github.com/(?[^/]+)/(?[^/]+)/pull/(?\d+)") +if ($PullRequestUrl -and $PullRequestUrl -match $regex) +{ + $owner = $matches['owner'] + $repo = $matches['repo'] + $prNumber = $matches['prNumber'] + + # Generate comment to add release plan context + $comment = "## Release plan details`nTitle: $ReleasePlanTitle`nLink: [$releasePlanLink]($releasePlanLink)`nSubmitted by: $releasePlanSubmittedBy" + try + { + $resp = Add-GitHubIssueComment -RepoOwner $owner -RepoName $repo -IssueNumber $prNumber -Comment $comment -AuthToken $AuthToken + LogDebug "Added comment to PR $prNumber in $owner/$repo" + } + catch + { + LogError "Failed to add comment to PR $prNumber in $owner/$repo. Error: $_" + } +} \ No newline at end of file From d58fad8ebd8596e53e7be18c0442e9ba248f64dc Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Fri, 5 Sep 2025 12:43:37 -0400 Subject: [PATCH 3/5] Removed the logic to add comment --- .../Helpers/DevOps-WorkItem-Helpers.ps1 | 5 ++++ .../Update-PullRequest-In-ReleasePlan.ps1 | 29 +------------------ 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 3f37d4bbb060..1d4076c4b6b0 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1104,5 +1104,10 @@ function Get-ReleasePlan-Link($releasePlanWorkItemId) $fieldList = ($fields | ForEach-Object { "[$_]"}) -join ", " $query = "SELECT ${fieldList} FROM WorkItems WHERE [System.Id] = $releasePlanWorkItemId" $workItem = Invoke-Query $fields $query + if (!$workItem) + { + Write-Host "Release plan with ID $releasePlanWorkItemId not found." + return $null + } return $workItem["fields"] } \ No newline at end of file diff --git a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 index ed7e929733ee..77008c88aa99 100644 --- a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 +++ b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 @@ -44,31 +44,4 @@ if (!$releasePlan) LogDebug "Updating pull request in release plan" Update-PullRequestInReleasePlan $ReleasePlanWorkItemId $PullRequestUrl $Status $LanguageName - -$releasePlanLink = $releasePlan["Custom.ReleasePlanLink"] -$releasePlanSubmittedBy = $releasePlan["Custom.ReleasePlanSubmittedby"] -$ReleasePlanTitle = $releasePlan["System.Title"] -LogDebug "Release plan title: $ReleasePlanTitle" -LogDebug "Release plan link: $releasePlanLink" -Write-Host "Submitted by: $releasePlanSubmittedBy" - -# Add a comment in pull request to provide release plan context -$regex = [regex]::new("https://github.com/(?[^/]+)/(?[^/]+)/pull/(?\d+)") -if ($PullRequestUrl -and $PullRequestUrl -match $regex) -{ - $owner = $matches['owner'] - $repo = $matches['repo'] - $prNumber = $matches['prNumber'] - - # Generate comment to add release plan context - $comment = "## Release plan details`nTitle: $ReleasePlanTitle`nLink: [$releasePlanLink]($releasePlanLink)`nSubmitted by: $releasePlanSubmittedBy" - try - { - $resp = Add-GitHubIssueComment -RepoOwner $owner -RepoName $repo -IssueNumber $prNumber -Comment $comment -AuthToken $AuthToken - LogDebug "Added comment to PR $prNumber in $owner/$repo" - } - catch - { - LogError "Failed to add comment to PR $prNumber in $owner/$repo. Error: $_" - } -} \ No newline at end of file +LogDebug "Updated pull request in release plan" \ No newline at end of file From 18db5c4260ddce8055b94b8cdb8906e947cb1787 Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Fri, 5 Sep 2025 12:47:40 -0400 Subject: [PATCH 4/5] Removed auth token --- eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 index 77008c88aa99..53a00bc253a9 100644 --- a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 +++ b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 @@ -6,9 +6,7 @@ param( [Parameter(Mandatory = $true)] $Status, [Parameter(Mandatory = $true)] - $LanguageName, - [Parameter(Mandatory = $true)] - $AuthToken + $LanguageName ) <# @@ -27,9 +25,6 @@ The status of the pull request. .PARAMETER LanguageName The programming language associated with the pull request. -.PARAMETER AuthToken -The authentication token for GitHub API. - #> Set-StrictMode -Version 3 From 4e2803f35c065829b3c83fe470086dd779c5d634 Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Fri, 5 Sep 2025 12:51:50 -0400 Subject: [PATCH 5/5] Removed get release plan link call --- eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 index 53a00bc253a9..cb40f5773067 100644 --- a/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 +++ b/eng/common/scripts/Update-PullRequest-In-ReleasePlan.ps1 @@ -31,11 +31,6 @@ Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) . (Join-Path $PSScriptRoot Helpers DevOps-WorkItem-Helpers.ps1) -$releasePlan = Get-ReleasePlan-Link $ReleasePlanWorkItemId -if (!$releasePlan) -{ - LogError "Release plan with ID $ReleasePlanWorkItemId not found." -} LogDebug "Updating pull request in release plan" Update-PullRequestInReleasePlan $ReleasePlanWorkItemId $PullRequestUrl $Status $LanguageName