Skip to content

Commit c8cd5c4

Browse files
authored
Sync eng/common directory with azure-sdk-tools for PR 13750 (#47838)
* Mark package as released using azsdk cli command
1 parent 927c307 commit c8cd5c4

File tree

3 files changed

+43
-26
lines changed

3 files changed

+43
-26
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
parameters:
2+
InstallDirectory: $(Agent.TempDirectory)
3+
SourceRootPath: '$(System.DefaultWorkingDirectory)'
4+
5+
steps:
6+
- task: Powershell@2
7+
displayName: 'Install Azure SDK Tools CLI'
8+
inputs:
9+
targetType: 'inline'
10+
script: |
11+
& "${{ parameters.SourceRootPath }}/eng/common/mcp/azure-sdk-mcp.ps1" -InstallDirectory ${{ parameters.InstallDirectory }}
12+
$azsdkPath = Join-Path "${{ parameters.InstallDirectory }}" "azsdk$(if ($IsWindows) { '.exe' } else { '' })"
13+
Write-Host "##vso[task.setvariable variable=AZSDK]$azsdkPath"
14+
Write-Host "Set AZSDK variable to: $azsdkPath"
15+
pwsh: true
16+
workingDirectory: $(Pipeline.Workspace)

eng/common/pipelines/templates/steps/mark-release-completion.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ parameters:
44
SourceRootPath: $(Build.SourcesDirectory)
55

66
steps:
7+
- template: /eng/common/pipelines/templates/steps/install-azsdk-cli.yml
8+
parameters:
9+
SourceRootPath: ${{ parameters.SourceRootPath }}
10+
711
- task: AzureCLI@2
812
inputs:
913
azureSubscription: opensource-api-connection
1014
scriptType: pscore
1115
scriptLocation: scriptPath
1216
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Mark-ReleasePlanCompletion.ps1
13-
arguments: -PackageInfoFilePath '${{ parameters.ConfigFileDir }}/${{ parameters.PackageArtifactName }}.json'
17+
arguments: >
18+
-PackageInfoFilePath '${{ parameters.ConfigFileDir }}/${{ parameters.PackageArtifactName }}.json' -AzsdkExePath '$(AZSDK)'
1419
workingDirectory: $(Pipeline.Workspace)
1520
displayName: Mark package as released
1621
continueOnError: true

eng/common/scripts/Mark-ReleasePlanCompletion.ps1

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
param(
22
[Parameter(Mandatory = $true)]
3-
[string]$PackageInfoFilePath
3+
[string]$PackageInfoFilePath,
4+
[Parameter(Mandatory = $true)]
5+
[string]$AzsdkExePath
46
)
57

68
<#
@@ -12,12 +14,20 @@ param(
1214
1315
.PARAMETER PackageInfoFilePath
1416
The path to the package information file (required) or path to the directory containing package information files.
17+
18+
.PARAMETER AzsdkExePath
19+
The path to the azsdk executable used to mark the release completion.
1520
#>
1621

1722
Set-StrictMode -Version 3
1823
. (Join-Path $PSScriptRoot common.ps1)
19-
. (Join-Path $PSScriptRoot Helpers DevOps-WorkItem-Helpers.ps1)
2024

25+
#Validate azsdk executable path
26+
if (-Not (Test-Path $AzsdkExePath))
27+
{
28+
Write-Error "The azsdk executable was not found at path '$AzsdkExePath'. Please ensure the executable exists and the path is correct."
29+
exit 1
30+
}
2131

2232
#Get package properties
2333
if (-Not (Test-Path $PackageInfoFilePath))
@@ -30,35 +40,21 @@ function Process-Package([string]$packageInfoPath)
3040
{
3141
# Get package info from json file created before updating version to daily dev
3242
$pkgInfo = Get-Content $packageInfoPath | ConvertFrom-Json
33-
$PackageVersion = $pkgInfo.Version
3443
$PackageName = $pkgInfo.Name
35-
if (!$PackageName -or !$PackageVersion)
44+
if (!$PackageName)
3645
{
37-
Write-Host "Package name or version is not available in the package information file. Skipping the release plan status update for the package."
46+
Write-Host "Package name is not available in the package information file. Skipping the release plan status update for the package."
3847
return
39-
}
48+
}
4049

41-
# Check Azure DevOps Release Plan work items
42-
Write-Host "Checking active release plan work items for package: $PackageName"
43-
$workItems = Get-ReleasePlanForPackage $PackageName
44-
if(!$workItems)
50+
Write-Host "Marking release completion for package, name: $PackageName"
51+
$releaseInfo = & $AzsdkExePath release-plan update-release-status --package-name $PackageName --language $LanguageDisplayName --status "Released"
52+
if ($LASTEXITCODE -ne 0)
4553
{
46-
Write-Host "No active release plans found for package name: $PackageName."
47-
return
48-
}
49-
50-
$activeReleasePlan = $workItems
51-
if($workItems.Count -gt 1 -and ($workItems -is [System.Array]))
52-
{
53-
$concatenatedIds = ($workItems | Select-Object -ExpandProperty id) -join ','
54-
Write-Host "Multiple release plans found for package name: $PackageName with work item IDs: $concatenatedIds. Using the first release plan to update release status."
55-
$activeReleasePlan = $workItems[0]
54+
## Not all releases have a release plan. So we should not fail the script even if a release plan is missing.
55+
Write-Host "Failed to mark release completion for package '$PackageName' using azsdk. Exit code: $LASTEXITCODE"
5656
}
57-
# Update release status
58-
Write-Host "Release plan work item ID: $($activeReleasePlan["id"])"
59-
Write-Host "Marking release completion for package, name: $PackageName version: $PackageVersion"
60-
Update-ReleaseStatusInReleasePlan $activeReleasePlan.id "Released" $PackageVersion
61-
Write-Host "Successfully marked release completion for package, name: $PackageName version: $PackageVersion."
57+
Write-Host "Details: $releaseInfo"
6258
}
6359

6460
Write-Host "Finding all package info files in the path: $PackageInfoFilePath"

0 commit comments

Comments
 (0)