Keep migration to new endpoint

This commit is contained in:
Alitzel Mendez 2025-12-08 16:10:25 -08:00 committed by azure-sdk
parent ef74176810
commit 28ae0f9bba

View File

@ -1,11 +1,9 @@
[CmdletBinding()]
Param (
[Parameter(Mandatory=$False)]
[array] $ArtifactList,
[Parameter(Mandatory=$True)]
[string] $ArtifactPath,
[array] $ArtifactList,
[Parameter(Mandatory=$False)]
[string] $APIKey,
[string] $ArtifactPath,
[string] $SourceBranch,
[string] $DefaultBranch,
[string] $RepoName,
@ -97,25 +95,17 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
$uri = "${APIViewUri}/upload"
# Try Bearer token first, fall back to API key
# Get Bearer token for authentication
$bearerToken = Get-ApiViewBearerToken
if ($bearerToken) {
$headers = @{
"Authorization" = "Bearer $bearerToken";
"content-type" = "multipart/form-data"
}
}
elseif ($APIKey) {
Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key."
$headers = @{
"ApiKey" = $APIKey;
"content-type" = "multipart/form-data"
}
}
else {
Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey."
if (-not $bearerToken) {
Write-Error "Failed to acquire Bearer token for APIView authentication."
return 401
}
$headers = @{
"Authorization" = "Bearer $bearerToken";
"content-type" = "multipart/form-data"
}
try
{
@ -156,23 +146,16 @@ function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $review
Write-Host "Request to APIView: $uri"
# Try Bearer token first, fall back to API key
# Get Bearer token for authentication
$bearerToken = Get-ApiViewBearerToken
if ($bearerToken) {
$headers = @{
"Authorization" = "Bearer $bearerToken"
}
}
elseif ($APIKey) {
Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key. Please migrate to using AzureCLI@2 task with service connection."
$headers = @{
"ApiKey" = $APIKey
}
}
else {
Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey."
if (-not $bearerToken) {
Write-Error "Failed to acquire Bearer token for APIView authentication."
return 401
}
$headers = @{
"Authorization" = "Bearer $bearerToken"
}
try
{