Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the version controller script to use Find-PSResource
against an Azure Artifacts feed (or fallback repository) instead of Find-Module
from PSGallery.
- Introduces conditional logic to detect
DEFAULT_PS_REPOSITORY_URL
and use credentials for Azure Artifacts - Switches
Find-Module
calls in bothBump-AzVersion
andUpdate-AzPreviewChangelog
toFind-PSResource
- Adds version filtering and sorting for LTS releases
$galleryAz = Find-PSResource -Name AzPreview -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | ||
} | ||
else { | ||
$galleryAz = Find-PSResource -Name AzPreview -Repository $GalleryName -Version * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside the LTS branch, the command references 'AzPreview' instead of 'Az', which breaks the original LTS logic for bumping the stable Az module. It should use -Name Az
to fetch the correct module.
$galleryAz = Find-PSResource -Name AzPreview -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | |
} | |
else { | |
$galleryAz = Find-PSResource -Name AzPreview -Repository $GalleryName -Version * | |
$galleryAz = Find-PSResource -Name Az -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | |
} | |
else { | |
$galleryAz = Find-PSResource -Name Az -Repository $GalleryName -Version * |
Copilot uses AI. Check for mistakes.
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { | ||
Write-Host "Using DEFAULT_PS_REPOSITORY_NAME: $Env:DEFAULT_PS_REPOSITORY_NAME" | ||
$AccessTokenSecureString = $env:SYSTEM_ACCESS_TOKEN | ConvertTo-SecureString -AsPlainText -Force | ||
$credentialsObject = [pscredential]::new("ONEBRANCH_TOKEN", $AccessTokenSecureString) | ||
$galleryAz = Find-PSResource -Name AzPreview -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | ||
} | ||
else { | ||
$galleryAz = Find-PSResource -Name AzPreview -Repository $GalleryName -Version * | ||
} | ||
$galleryAz = $galleryAz | Where-Object { ([System.Version]($_.Version)).Major%2 -eq 0 } | Sort-Object {[System.Version]$_.Version} -Descending | ||
} | ||
else | ||
{ | ||
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { | ||
Write-Host "Using DEFAULT_PS_REPOSITORY_NAME: $Env:DEFAULT_PS_REPOSITORY_NAME" | ||
$AccessTokenSecureString = $env:SYSTEM_ACCESS_TOKEN | ConvertTo-SecureString -AsPlainText -Force | ||
$credentialsObject = [pscredential]::new("ONEBRANCH_TOKEN", $AccessTokenSecureString) | ||
$galleryAz = Find-PSResource -Name AzPreview -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | ||
} | ||
else { | ||
$galleryAz = Find-PSResource -Name AzPreview -Repository $GalleryName | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The repository-detection and credential setup blocks are duplicated in both release branches. Consider extracting this into a helper function to reduce duplication and simplify future updates.
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { | |
Write-Host "Using DEFAULT_PS_REPOSITORY_NAME: $Env:DEFAULT_PS_REPOSITORY_NAME" | |
$AccessTokenSecureString = $env:SYSTEM_ACCESS_TOKEN | ConvertTo-SecureString -AsPlainText -Force | |
$credentialsObject = [pscredential]::new("ONEBRANCH_TOKEN", $AccessTokenSecureString) | |
$galleryAz = Find-PSResource -Name AzPreview -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | |
} | |
else { | |
$galleryAz = Find-PSResource -Name AzPreview -Repository $GalleryName -Version * | |
} | |
$galleryAz = $galleryAz | Where-Object { ([System.Version]($_.Version)).Major%2 -eq 0 } | Sort-Object {[System.Version]$_.Version} -Descending | |
} | |
else | |
{ | |
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { | |
Write-Host "Using DEFAULT_PS_REPOSITORY_NAME: $Env:DEFAULT_PS_REPOSITORY_NAME" | |
$AccessTokenSecureString = $env:SYSTEM_ACCESS_TOKEN | ConvertTo-SecureString -AsPlainText -Force | |
$credentialsObject = [pscredential]::new("ONEBRANCH_TOKEN", $AccessTokenSecureString) | |
$galleryAz = Find-PSResource -Name AzPreview -Repository $Env:DEFAULT_PS_REPOSITORY_NAME -Credential $credentialsObject -TrustRepository | |
} | |
else { | |
$galleryAz = Find-PSResource -Name AzPreview -Repository $GalleryName | |
} | |
$galleryAz = Get-GalleryAz -ReleaseType "LTS" -GalleryName $GalleryName | |
$galleryAz = $galleryAz | Where-Object { ([System.Version]($_.Version)).Major%2 -eq 0 } | Sort-Object {[System.Version]$_.Version} -Descending | |
} | |
else | |
$galleryAz = Get-GalleryAz -ReleaseType "STS" -GalleryName $GalleryName |
Copilot uses AI. Check for mistakes.
$galleryAz = (Find-Module -Name Az -Repository $GalleryName -AllVersions | Where-Object {([System.Version]($_.Version)).Major%2 -eq 0} | Sort-Object {[System.Version]$_.Version} -Descending)[0] | ||
}else{ | ||
$galleryAz = Find-Module -Name Az -Repository $GalleryName | ||
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Using Test-Path
to check for an environment variable can be misleading—consider directly testing $env:DEFAULT_PS_REPOSITORY_URL
(e.g. if (-not [string]::IsNullOrEmpty($env:DEFAULT_PS_REPOSITORY_URL))
) to ensure the variable is both present and nonempty.
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { | |
if (-not [string]::IsNullOrEmpty($env:DEFAULT_PS_REPOSITORY_URL)) { |
Copilot uses AI. Check for mistakes.
}else{ | ||
$galleryAz = Find-Module -Name Az -Repository $GalleryName | ||
if (Test-Path Env:\DEFAULT_PS_REPOSITORY_URL) { | ||
Write-Host "Using DEFAULT_PS_REPOSITORY_NAME: $Env:DEFAULT_PS_REPOSITORY_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using Write-Verbose
instead of Write-Host
for informational messages so that consumers can control verbosity with the -Verbose
switch.
Copilot uses AI. Check for mistakes.
Description
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.md
and reviewed the following information:ChangeLog.md
file(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
.## Upcoming Release
header in the past tense.ChangeLog.md
if no new release is required, such as fixing test case only.