使用 Jenkins,我在嘗試將節點專案(React 應用程式)發布到 Nexus 時遇到錯誤。
管道腳本:
node ("test-label") {
stage('checkout'){
sh 'git clone -b react-1 https://gitlab.com/.../ui/test.git .'
}
stage ('Build'){
container('node'){
script {
sh "set x && echo \"//mynexusurl/repository/npm-private/:_authToken=NpmToken.******\" >> .npmrc"
sh 'npm publish'
}
}
}
}
錯誤:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/
npm ERR! need auth You need to authorize this machine using `npm adduser`
如果我在專案中的 package.json 檔案中添加以下代碼,它可以正常作業,但我不想在 package.json 檔案中輸入這些資訊。
"publishConfig": {
"registry": "http://mynexus/repository/npm-private/"
}
如何在不提供publishConfig資訊的情況下修復package.json ?
uj5u.com熱心網友回復:
我按如下方式解決了問題
sh "npm publish --registry http://nexusurl/repository/npm-private/"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/535715.html
