Details
-
Type:
Bug
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Not A Defect
-
Component/s: nodejs-plugin
-
Labels:None
-
Environment:Jenkins ver 2.44
Nodejs Plugin 1.2.2
-
Similar Issues:
Description
I have a multi-branch pipeline for a private NPM package.
Within my Jenkinsfile I have a defined a "Publish" stage within my pipeline script for automatically deploying after a successful CI build. This stage looks like:
stage('Publish') { if (env.BRANCH_NAME == "master" || env.BRANCH_NAME == "develop" || env.BRANCH_NAME.startsWith("release/") || env.BRANCH_NAME.startsWith('hotfix/')) { nodejs(nodeJSInstallationName: 'NodeJS 6.x', configId: 'abcdefgh-1234-5678-9999-0987654321') { sh 'npm login' sh 'npm publish' } } else if (env.BRANCH_NAME.startsWith('feature/')) { echo "On A feature branch. Not publishing!" } else { echo "Skipping publish - This build is not ocurring on a publish-able branch!" } }
When the script for npm login fires I get an error:
[Pipeline] sh
[workspace] Running shell script
+ npm adduser
Username: (jenkins) npm ERR! cb() never called!
I could put the credentials in the script, but man does that suck. I spent a good amount of time setting up the credentials repository in Jenkins so that slick developers wouldn't be able to hold me hostage!
How can I get authentication to work?
Other notes:
We're internally using Sonatype Nexus for our internal hosted NPM registry. I have two configuration files stored, one for accessing the proxy repository (combo of public npmjs and our hosted) and our hosted.
In our organisation we use artifactory. We use it to download and publish npm package.
The generated .npmrc has credentials to perform the npm publish command, I do not if there is other settings to add for npm login and I do not know why you need to perform login when you publish.
Anyway please post the generated .npmrc and take care to hide the personal informations.
For more information have a look to the issue
JENKINS-40364