From 4569e001c86e70d76689f714d026d6d6c3fc7755 Mon Sep 17 00:00:00 2001 From: MaddoScientisto Date: Mon, 16 Feb 2026 23:54:32 +0100 Subject: [PATCH] Update NuGet auth to use CI_JOB_TOKEN in CI scripts Switched private NuGet source authentication in build_windows and publish_release jobs to use CI_JOB_TOKEN instead of NUGET_USERNAME/NUGET_PASSWORD. Updated related log messages and ensured PowerShell variable usage is correct for environment variables. This improves compatibility with GitLab CI best practices. --- .gitlab-ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55d000a..8a7267c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,14 +44,14 @@ build_windows: $dotnetExe = 'dotnet' } - # Configure private NuGet source from GitLab Packages if credentials are provided + # Configure private NuGet source from GitLab Packages using CI_JOB_TOKEN $nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json' - if ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) { - Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS...' + 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 $CI_JOB_TOKEN --store-password-in-clear-text + & $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username gitlab-ci-token --password $env:CI_JOB_TOKEN --store-password-in-clear-text } else { - Write-Host 'NUGET_USERNAME/NUGET_PASSWORD not set; skipping private NuGet source configuration.' + Write-Host 'CI_JOB_TOKEN not available; skipping private NuGet source configuration.' } & $dotnetExe --info @@ -87,14 +87,14 @@ publish_release: & $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained false -o publish Write-Host "Published to $(pwd)\\publish" - # Configure private NuGet source from GitLab Packages if credentials are provided + # Configure private NuGet source from GitLab Packages using CI_JOB_TOKEN $nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json' - if ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) { - Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS...' + 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 $CI_JOB_TOKEN --store-password-in-clear-text + & $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username gitlab-ci-token --password $env:CI_JOB_TOKEN --store-password-in-clear-text } else { - Write-Host 'NUGET_USERNAME/NUGET_PASSWORD not set; skipping private NuGet source configuration.' + Write-Host 'CI_JOB_TOKEN not available; skipping private NuGet source configuration.' } # Find first file in publish folder