Support NuGet auth fallback and add feed diagnostics
Enhance private NuGet source setup in build_windows and publish_release jobs to support fallback authentication using NUGET_USERNAME/NUGET_PASSWORD when CI_JOB_TOKEN is unavailable. Update log messages for clarity. Add diagnostic steps in build_windows to verify NuGet feed and package visibility using configured credentials. No changes to core build or publish logic.
This commit is contained in:
parent
4569e001c8
commit
8db7ee8075
1 changed files with 35 additions and 2 deletions
|
|
@ -45,16 +45,44 @@ build_windows:
|
|||
}
|
||||
|
||||
# Configure private NuGet source from GitLab Packages using CI_JOB_TOKEN
|
||||
# Fallback to repository variables NUGET_USERNAME/NUGET_PASSWORD for shared runners
|
||||
$nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json'
|
||||
$authMode = $null
|
||||
if ($env:CI_JOB_TOKEN) {
|
||||
Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using CI_JOB_TOKEN...'
|
||||
try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {}
|
||||
& $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username gitlab-ci-token --password $env:CI_JOB_TOKEN --store-password-in-clear-text
|
||||
$authMode = 'JobToken'
|
||||
} elseif ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) {
|
||||
Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using NUGET_USERNAME/NUGET_PASSWORD...'
|
||||
try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {}
|
||||
& $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text
|
||||
$authMode = 'UserCreds'
|
||||
} else {
|
||||
Write-Host 'CI_JOB_TOKEN not available; skipping private NuGet source configuration.'
|
||||
Write-Host 'No credentials available; skipping private NuGet source configuration.'
|
||||
}
|
||||
|
||||
& $dotnetExe --info
|
||||
# Diagnostic: verify GitLab NuGet feed and package visibility using configured auth
|
||||
if ($authMode) {
|
||||
Write-Host 'Checking GitLab NuGet feed index and project packages for AIFotoONLUS.Core using auth mode:' $authMode
|
||||
try {
|
||||
if ($authMode -eq 'JobToken') {
|
||||
$headers = @{ 'JOB-TOKEN' = $env:CI_JOB_TOKEN }
|
||||
} else {
|
||||
$pair = "$env:NUGET_USERNAME:$env:NUGET_PASSWORD"
|
||||
$b64 = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair))
|
||||
$headers = @{ Authorization = "Basic $b64" }
|
||||
}
|
||||
Invoke-RestMethod -Uri $nugetUrl -Headers $headers -Method Get | ConvertTo-Json | Write-Host
|
||||
} catch { Write-Host "Failed to fetch feed index: $_" }
|
||||
try {
|
||||
$pkgApi = "https://gitlab.com/api/v4/projects/79509532/packages?package_name=AIFotoONLUS.Core"
|
||||
Invoke-RestMethod -Uri $pkgApi -Headers $headers -Method Get | ConvertTo-Json | Write-Host
|
||||
} catch { Write-Host "Failed to query project packages API: $_" }
|
||||
} else {
|
||||
Write-Host 'Skipping feed diagnostics because no auth configured.'
|
||||
}
|
||||
& $dotnetExe restore
|
||||
& $dotnetExe build "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -v minimal
|
||||
}
|
||||
|
|
@ -88,13 +116,18 @@ publish_release:
|
|||
Write-Host "Published to $(pwd)\\publish"
|
||||
|
||||
# Configure private NuGet source from GitLab Packages using CI_JOB_TOKEN
|
||||
# Fallback to repository variables NUGET_USERNAME/NUGET_PASSWORD for shared runners
|
||||
$nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json'
|
||||
if ($env:CI_JOB_TOKEN) {
|
||||
Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using CI_JOB_TOKEN...'
|
||||
try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {}
|
||||
& $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username gitlab-ci-token --password $env:CI_JOB_TOKEN --store-password-in-clear-text
|
||||
} elseif ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) {
|
||||
Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using NUGET_USERNAME/NUGET_PASSWORD...'
|
||||
try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {}
|
||||
& $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text
|
||||
} else {
|
||||
Write-Host 'CI_JOB_TOKEN not available; skipping private NuGet source configuration.'
|
||||
Write-Host 'No credentials available; skipping private NuGet source configuration.'
|
||||
}
|
||||
|
||||
# Find first file in publish folder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue