Skip to content

Not working with GitLab NuGet feed #215

@agowa

Description

@agowa

I tried to configure PowerShell Get with an GitLab Nuget Package Repository and it fails.

PS /> $parameters = @{
  Name = "GitLab"
  SourceLocation = "https://git.internal/api/v4/projects/916/packages/nuget/index.json"
  PublishLocation = "https://git.internal/api/v4/projects/916/packages/nuget/index.json"
  InstallationPolicy = 'Trusted'
  Credential = $(Get-PSCredential)
}
PS /> Register-PSRepository @parameters
WARNING: Unable to resolve package source 'https://git.internal/api/v4/projects/916/packages/nuget/index.json'.

This repository works fine with nuget.exe, but not with PowerShell get.

PS /> nuget source Add -Name "GitLab" -Source "https://git.internal/api/v4/projects/916/packages/nuget/index.json" -UserName "gitlab+deploy-token-11" -Password "eobaiX8ivaich9ooh8Ei"

I'm using a gitlab deploy token in both cases (credentials changed of course).

Within powershell it doesn't work and only outputs errors:

PS /> Publish-Module -Name PSReadLine -Repository GitLab -NuGetApiKey "a" -RequiredVersion 2.0.3 -Credential $gitlabToken
Write-Error: /home/user/.local/share/powershell/Modules/PowerShellGet/2.2.4.1/PSModule.psm1:10988
 Line |
10988 |  …             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param …
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Failed to publish module 'PSReadLine': 'dotnet cli failed to nuget push error: Unable to load the service index for source
      | https://git.internal/api/v4/projects/916/packages/nuget/index.json. error:   Response status code does not indicate success: 401 (Unauthorized). '.

GitLab is providing the NuGet Version: "3.0.0" according to the json output of the api.
It doesn't use any ApiKeys.

Documentation from GitLab can be found at: https://docs.gitlab.com/ee/user/packages/nuget_repository/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions