My company has a Nexus 3 server where we store all of our artifacts for a predominantly Maven environment. I'm trying to use Node to do the same things as Maven:
- Deploy to a snapshots or releases directory based on a non-hard-coded flag (could be in Jenkins job)
- Automatically append an additional version variable to snapshots so that it can be "overridden". Since Nexus only likes unique names, I'd need some way to store the built artifact as x.y.z-SNAPSHOT.1, then x.y.z-SNAPSHOT.2 so that a fetch of x.y.z-SNAPSHOT will pull the latest
Ideally, the only difference between build/deploying a SNAPSHOT and a RELEASE would be npm publish <snapshot/release indicator flag>
and it could look up, in say the .npmrc file the URL, but use credentials defined on the machine doing the build/deploy (so that developers don't have master credentials). I'm having trouble setting this up. The NPM scope looks promising, but that may only apply to packages/projects that would have one scope and not conditional ones.
I've currently tried an npm publish --registry=<url>
, but it failed with an error saying I need to use npm adduser
. I'm unsure of exactly how to supply the credentials and which to give it (am I giving it credentials for the Nexus user to store the artifact, or is NPM simply not allowing the current user (Jenkins user) to publish?).