Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45854

Authentication for registry within declarative pipeline fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • nodejs-plugin
    • None
    • Jenkins ver 2.44
      Nodejs Plugin 1.2.2

      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.

            nfalco Nikolas Falco
            mikejr83 Michael Gardner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: