5

This is driving me nuts. I have installed Nexus 3 OSS to use as a private NuGet-repository and created a user foe jenkins. I got an ApiKey for the jenkins user the way the documentation shows and now I try to push my packages to the repo with

nuget push .\AMAP.*.symbols.nupkg -Source http://nexus.local:8081/repository/nuget-hosted/ -ApiKey <JenkinsApiKeyHere>

But if I do this I am asked for username and password. I tried to set username and password to my configuration as suggested by some sources found on the net like this:

nuget sources update -Name my-nuget -username jenkins -password <supersecretjenkinspwd>

But still I am asked for username and password!? By the way, the anonymous access to nexus is granted as shown in the sonatype docs.

As you can see from above I am trying to do this from a jenkins build server and I already tried the nexus artifact uploader plugin without success. It fails with a NullPointer:

java.lang.NullPointerException
    at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep.getUsername(NexusArtifactUploaderStep.java:132)

So I think it has the same problem. How can I achieve to push my NuGet-packages to Nexus without user interaction?

Frank
  • 2,036
  • 1
  • 20
  • 32

1 Answers1

14

Ok, I found the solution myself. I needed to add the NuGet API-Key Realm to the active realms. By default it is not active thus preventing the ApiKey from being considered as valid credential. This is done under Settings -> Security -> Realms.

Frank
  • 2,036
  • 1
  • 20
  • 32
  • hi Frank. Am new to Jenkins. Am doing nuget push -Source . When this is run in pipeline script, am getting an un-authorization error. Can u please help me out where exactly I will have to update api key, user name and password in jenkins? And where can I find this setting that u r talking about? – suhas_partha Feb 04 '20 at 08:19
  • Hey I found it! Thanks. It was the settings in nexus oss – suhas_partha Feb 04 '20 at 09:35
  • Do you need both username:password and API key to upload with nuget push? Or either is good enough? – Vesper Mar 23 '22 at 08:29