如何解决使用 Jenkins 错误发布到私有存储库
错误是:npm ERR! need auth You need to authorize this machine using npm adduser
我可以在本地发布它,但它在管道中不起作用。
我已将 npm Bearer Token Realm 添加到我的连接领域中的“活动”。
你可以看到我发布了“whoami”,我得到了“管理员”。
我也使用注册表标志来仔细检查。
这是一个 npm 库,npm publish 将在本地运行。问题是运行 NPM 发布时 jenkins 文件遇到构建错误。
package.json:
{
"name": "femadex-shared-library","version": "0.0.0","publishConfig": {
"cache": "~/.npm","registry": "https://EXAMPLE.net/repository/femadex-npm-private/"
},"scripts": {
"ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
},"dependencies": {
"@angular/animations": "~9.1.9","@angular/common": "~9.1.9","@angular/compiler": "~9.1.9","@angular/core": "~9.1.9","@angular/forms": "~9.1.9","@angular/platform-browser": "~9.1.9","@angular/platform-browser-dynamic": "~9.1.9","@angular/router": "~9.1.9","rxjs": "~6.5.4","tslib": "^1.10.0","zone.js": "~0.10.2"
},"devDependencies": {
"@angular-devkit/build-angular": "~0.901.7","@angular-devkit/build-ng-packagr": "~0.901.13","@angular/cli": "~9.1.7","@angular/compiler-cli": "~9.1.9","@types/jasmine": "~3.5.0","@types/jasminewd2": "~2.0.3","@types/node": "^12.11.1","codelyzer": "^5.1.2","jasmine-core": "~3.5.0","jasmine-spec-reporter": "~4.2.1","karma": "~5.0.0","karma-chrome-launcher": "~3.1.0","karma-coverage-istanbul-reporter": "~2.1.0","karma-jasmine": "~3.0.1","karma-jasmine-html-reporter": "^1.4.2","ng-packagr": "^9.0.0","protractor": "~7.0.0","ts-node": "~8.3.0","tslint": "~6.1.0","typescript": "~3.8.3"
}
}
.npmrc:
registry=https://EXAMPLE.net/repository/femadex-npm-private/
_auth="****"
always-auth=true
strict-ssl = false
詹金斯文件的片段:
script {
checkout scm
sh """
chmod 644 .npmrc
ls -la
cat .npmrc
# install dev modules
npm config set registry https://EXAMPLE.net/repository/femadex-npm-private/
npm whoami --registry=https://EXAMPLE.net/repository/femadex-npm-private
npm install -g @angular/cli
#npm version $LIB_MAJOR.$LIB_MINOR.#BUILD_NUMBER
ng build femadex-shared-library
npm whoami
npm publish --registry https://EXAMPLE.net/repository/femadex-npm-private/
"""
}
+ npm whoami
admin
+ npm whoami --registry=https://EXAMPLE.net/repository/femadex-npm-private
admin
+ npm publish --registry https://EXAMPLE.net/repository/femadex-npm-private/
...
...
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`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。