我正在尝试运行Jenkins 2流水线(Jenkinsfile),使用npm publish
将软件包发布到本地NPM存储库。
为了实现这一目的,我尝试在Jenkinsfile中使用以下阶段:
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
"""
}
}
}
目前我只运行npm whoami
,一旦它能正常工作,我将用npm publish
替换它。
这是我得到的输出:
+ 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`
echo $NPM_TOKEN
会发生什么? - Rik