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

1

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?

Tull answered 5/6, 2018 at 12:48 Comment(0)
T
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.

Tull answered 11/6, 2018 at 9:46 Comment(3)
hi Frank. Am new to Jenkins. Am doing nuget push <artifact> -Source <repo_url>. 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?Questionless
Hey I found it! Thanks. It was the settings in nexus ossQuestionless
Do you need both username:password and API key to upload with nuget push? Or either is good enough?Lamm

© 2022 - 2024 — McMap. All rights reserved.