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