Search code examples
jenkinsnugetnexus3

Push to Nexus 3 NuGet-repository from Jenkins CI without being asked for credentials


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?


Solution

  • 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.