title: Jenkins 2 NPM_TOKEN credential
body: <p>I'm trying to run Jenkins 2 pipeline (Jenkinsfile) that will use <code>npm publish</code> to publish a package to local NPM repository.<br>
  In order to do that I've try to use the following stage in Jenkinsfile:</p>
  
  <pre><code>stage('TEST npm whoami') {
      withEnv(["PATH+NPM=${tool name: 'node-6', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'}/bin"]) {
      withCredentials([[$class: 'StringBinding', credentialsId: 'npm-token', variable: 'NPM_TOKEN']]) {
          sh """
             npm whoami
             """
      }
      }
  }
  </code></pre>
  
  <p>Currently I'm running only <code>npm  whoami</code> and once that will work I'll replace it with <code>npm publish</code>.</p>
  
  <p>This is the output I'm getting:</p>
  
  <pre><code>+ npm whoami
  npm ERR! Linux 4.7.5-1.el7.elrepo.x86_64
  npm ERR! argv "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node-6/bin/node" "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node-6/bin/npm" "whoami"
  npm ERR! node v6.5.0
  npm ERR! npm  v3.10.3
  npm ERR! code ENEEDAUTH
  
  npm ERR! need auth this command requires you to be logged in.
  npm ERR! need auth You need to authorize this machine using `npm adduser`
  </code></pre>