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

nodejs does not send credentials to NPM local registry

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Component/s: nodejs-plugin
    • Labels:
      None
    • Environment:
      windows server 2016
    • Similar Issues:

      Description

      I surround a bat 'npm publish' with a nodejs that contains a configuration id that specifies a registry and a credential.  This creates a config file in the workspace@tmp folder with the following entries:

      registry = http:/my-local-nexus.company.com:8081/repository/npm-hosted/
      always-auth = true
      _auth = <huge base64 string>

      at the end of the publish I get the following:

      npm ERR! code E401
      npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
      

        Attachments

          Activity

          Hide
          marioja Mario Jauvin added a comment -

          The only way to get it to work is by issuing a npm login command on windows 10 box and pick up the line

          //my-local-nexus.company.com:8081/repository/npm-hosted/:_authToken=NpmToken.xxxxxxxxxxxxxxx
          

          from the user profile .npmrc and copy it to the jenkins npmrc config file.  In that case the credential specified on the registry entry is not used at all.

          Show
          marioja Mario Jauvin added a comment - The only way to get it to work is by issuing a npm login command on windows 10 box and pick up the line //my-local-nexus.company.com:8081/repository/npm-hosted/:_authToken=NpmToken.xxxxxxxxxxxxxxx from the user profile .npmrc and copy it to the jenkins npmrc config file.  In that case the credential specified on the registry entry is not used at all.
          Hide
          nfalco Nikolas Falco added a comment - - edited

          Above you have configured credential for a global (proxy) registry in the post you had set a private registry (scoped), so what is you use case?

          This is the configuration guide for Nexus, if it works like artifactory email field is required or authentication fails. The plugin generate entries for a global (proxy) registry exactly as per npm documentation. Do not forget

          "publishConfig" : {
            "registry" : "http:/my-local-nexus.company.com:8081/repository/npm-hosted/"
          }
          

          in package.json (required).

           

          If you package is scoped (@mycompany/mypackage like @angular/compress) than remember to set the scope mycompany in the NPM config editor like in plugin documentation

          Show
          nfalco Nikolas Falco added a comment - - edited Above you have configured credential for a global (proxy) registry in the post you had set a private registry (scoped), so what is you use case? This is the configuration guide for Nexus , if it works like artifactory email field is required or authentication fails. The plugin generate entries for a global (proxy) registry exactly as per npm documentation. Do not forget "publishConfig" : { "registry" : "http:/my-local-nexus.company.com:8081/repository/npm-hosted/" } in package.json (required).   If you package is scoped (@mycompany/mypackage like @angular/compress) than remember to set the scope mycompany in the NPM config editor like in plugin documentation
          Hide
          marioja Mario Jauvin added a comment -

          I am not sure what above and in the post mean.  In the Jira description, I display the npmrc config file created by the nodejs jenkins plugin (I grabbed the file from the workspace@tmp folder while it existed).  The comment aug 27, 16:06 documents the output written to the ~/.npmrc by running the npm login command.  I do not have any scope defined.

          Show
          marioja Mario Jauvin added a comment - I am not sure what above and in the post mean.  In the Jira description, I display the npmrc config file created by the nodejs jenkins plugin (I grabbed the file from the workspace@tmp folder while it existed).  The comment aug 27, 16:06 documents the output written to the ~/.npmrc by running the npm login command.  I do not have any scope defined.
          Hide
          nfalco Nikolas Falco added a comment - - edited
          registry = http:/my-local-nexus.company.com:8081/repository/npm-hosted/
          always-auth = true
          _auth = <huge base64 string>
          

          Is exactly like NPM document the credential must be setup for a global registry. If does not work with nexus you need to setup env like nexus requires. Seems email entry is required so in the npm config file add email=mfj@earthling.net with a valid email account in your LDAP. This make it work for example in artifactory (also if email is not a required entry in NPM documentation).
          If you read the documentaion I posted it also explain as alternative use nexus as a scoped registry. Since I do not have you project I can not say if you have to configure it as global registry (that also act as proxy) or scoped. Read the whole documentation I posted to understand the difference and what it correct for you. The plugin generate credentials entries as NPM documents for global (private or public) or scoped (private) registries.

          Show
          nfalco Nikolas Falco added a comment - - edited registry = http:/my-local-nexus.company.com:8081/repository/npm-hosted/ always-auth = true _auth = <huge base64 string> Is exactly like NPM document the credential must be setup for a global registry. If does not work with nexus you need to setup env like nexus requires. Seems email entry is required so in the npm config file add email=mfj@earthling.net with a valid email account in your LDAP. This make it work for example in artifactory (also if email is not a required entry in NPM documentation). If you read the documentaion I posted it also explain as alternative use nexus as a scoped registry. Since I do not have you project I can not say if you have to configure it as global registry (that also act as proxy) or scoped. Read the whole documentation I posted to understand the difference and what it correct for you. The plugin generate credentials entries as NPM documents for global (private or public) or scoped (private) registries.

            People

            Assignee:
            nfalco Nikolas Falco
            Reporter:
            marioja Mario Jauvin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: