Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions eng/common/pipelines/templates/steps/install-azsdk-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
InstallDirectory: $(Agent.TempDirectory)
SourceRootPath: '$(System.DefaultWorkingDirectory)'

steps:
- task: Powershell@2
displayName: 'Install Azure SDK Tools CLI'
inputs:
targetType: 'inline'
script: |
& "${{ parameters.SourceRootPath }}/eng/common/mcp/azure-sdk-mcp.ps1" -InstallDirectory ${{ parameters.InstallDirectory }}
$azsdkPath = Join-Path "${{ parameters.InstallDirectory }}" "azsdk$(if ($IsWindows) { '.exe' } else { '' })"
Write-Host "##vso[task.setvariable variable=AZSDK]$azsdkPath"
Write-Host "Set AZSDK variable to: $azsdkPath"
pwsh: true
workingDirectory: $(Pipeline.Workspace)
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ parameters:
SourceRootPath: $(Build.SourcesDirectory)

steps:
- template: /eng/common/pipelines/templates/steps/install-azsdk-cli.yml
parameters:
InstallDirectory: $(Agent.TempDirectory)
SourceRootPath: ${{ parameters.SourceRootPath }}

- task: AzureCLI@2
inputs:
azureSubscription: opensource-api-connection
scriptType: pscore
scriptLocation: scriptPath
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Mark-ReleasePlanCompletion.ps1
arguments: -PackageInfoFilePath '${{ parameters.ConfigFileDir }}/${{ parameters.PackageArtifactName }}.json'
arguments: >
-PackageInfoFilePath '${{ parameters.ConfigFileDir }}/${{ parameters.PackageArtifactName }}.json' -AzsdkExePath '$(AZSDK)'
workingDirectory: $(Pipeline.Workspace)
displayName: Mark package as released
continueOnError: true
Expand Down
46 changes: 21 additions & 25 deletions eng/common/scripts/Mark-ReleasePlanCompletion.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
param(
[Parameter(Mandatory = $true)]
[string]$PackageInfoFilePath
[string]$PackageInfoFilePath,
[Parameter(Mandatory = $true)]
[string]$AzsdkExePath
)

<#
Expand All @@ -12,12 +14,20 @@ param(

.PARAMETER PackageInfoFilePath
The path to the package information file (required) or path to the directory containing package information files.

.PARAMETER AzsdkExePath
The path to the azsdk executable used to mark the release completion.
#>

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

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

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

# Check Azure DevOps Release Plan work items
Write-Host "Checking active release plan work items for package: $PackageName"
$workItems = Get-ReleasePlanForPackage $PackageName
if(!$workItems)
Write-Host "Marking release completion for package, name: $PackageName"
$releaseInfo = & $AzsdkExePath release-plan update-release-status --package-name $PackageName --language $LanguageDisplayName --status "Released"
if ($LASTEXITCODE -ne 0)
{
Write-Host "No active release plans found for package name: $PackageName."
return
}

$activeReleasePlan = $workItems
if($workItems.Count -gt 1 -and ($workItems -is [System.Array]))
{
$concatenatedIds = ($workItems | Select-Object -ExpandProperty id) -join ','
Write-Host "Multiple release plans found for package name: $PackageName with work item IDs: $concatenatedIds. Using the first release plan to update release status."
$activeReleasePlan = $workItems[0]
## Not all releases have a release plan. So we should not fail the script even if a release plan is missing.
Write-Host "Failed to mark release completion for package '$PackageName' using azsdk. Exit code: $LASTEXITCODE"
}
# Update release status
Write-Host "Release plan work item ID: $($activeReleasePlan["id"])"
Write-Host "Marking release completion for package, name: $PackageName version: $PackageVersion"
Update-ReleaseStatusInReleasePlan $activeReleasePlan.id "Released" $PackageVersion
Write-Host "Successfully marked release completion for package, name: $PackageName version: $PackageVersion."
Write-Host "Details: $releaseInfo"
}

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