choli
choli

Reputation: 322

Push NuGet Package to Artifactory local repo subfolder

I have set up a local NuGet Repository as described here. The apikey is set and authentication is also set in the NuGet.Config file.

To push a nupkg directly into this folder, there is no problem:

nuget push Nuget.0.1.15.nupkg -Source http://arti.url/artifactory/api/nuget/nuget-repo-local

But as soon as I try to push it to a subfolder to have kind of a nice layout in Artifactory, this fails:

nuget push Nuget.0.1.15.nupkg -Source http://arti.url/artifactory/api/nuget/nuget-repo-local/aFolder

Is this a known problem, does anybody have a solution to this? Creating an apikey for every folder is not really what I am looking for...

The warning is as follows:

WARNING: No API Key was provided and no API Key could be found for 'http://arti.url/artifactory/api/nuget/nuget-repo-local/aFolder'. 
To save an API Key for a source use the 'setApiKey' command.

And the error says then:

Failed to process request. 'Forbidden'. 
The remote server returned an error: (403) Forbidden..

Upvotes: 3

Views: 13369

Answers (1)

jroquelaure
jroquelaure

Reputation: 553

When you do :

nuget push Nuget.0.1.15.nupkg -Source http://arti.url/artifactory/api/nuget/nuget-repo-local/aFolder

nuget intrpret the whole url as the repo address (the client implementation is based on flat deployment where Artifactory is more flexible)

Regarding your deployment on root repo I assume you followed the indication and ran the setApiKey command first on the repo :

nuget setapikey <USERNAME>:<PASSWORD> -Source http://arti.url/artifactory/api/nuget/nuget-repo-local

this allow you to push without entering your credentials each time but only at root level.

Now if you want to push on subfolder you can set the apikey on it as you did for the rpo itself :

nuget setapikey <USERNAME>:<PASSWORD> -Source http://arti.url/artifactory/api/nuget/nuget-repo-local/aFolder

However you will have to do it on every folder

or use "apikey" option on push

nuget push Nuget.0.1.15.nupkg -Source http://arti.url/artifactory/api/nuget/nuget-repo-local/aFolder -apikey <USERNAME>:<PASSWORD>

or tick the option "Force authentication" on the repository configuration in Artifactory. This option will force you to enter your credentials and prevent your "403" error.

Upvotes: 6

Related Questions