从 Docker gitlab CI 在 Verdaccio 上发布 npm 模块
Publishing npm module on Verdaccio from Docker gitlab CI
我正在尝试从 Gitlab CI 运行ning 在 Docker 中在我的私人 Verdaccio 存储库上发布一个模块。我按照 this tutorial 并在我的主机上生成了令牌(因为将 运行 作业的容器在管道启动之前不存在)。
image: node:11-alpine
stages:
- test
- publish
before_script:
- npm set registry http://nodejs.repo.asts.com
- npm i
test:
stage: test
script:
- npm run lint
- npm t
coverage: '/All files\s*\|\s*(\d{1,3}(?:\.\d+)?)/'
publish:
stage: publish
script:
- echo "//nodejs.repo.asts.com/:_authToken=\"$NPM_AUTH_TOKEN\"" > ~/.npmrc
- cat ~/.npmrc
- npm whoami
- npm publish
作业失败并出现以下错误:
$ npm whoami
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`
但是cat
命令显示令牌具有预期值。
我不明白问题是 Verdaccio 不支持令牌还是我生成它的方式。我也找到了 plugin 但我不知道应该如何使用。
我应该如何配置我的 gitlab CI 以在 Verdaccio 上发布一个包?
它应该像@Hedge 所说的那样工作:将令牌保存在项目文件夹中的 .npmrc
文件中:
image: node:11-alpine
stages:
- test
- publish
before_script:
- npm set registry http://nodejs.repo.asts.com
- npm i
test:
stage: test
script:
- npm run lint
- npm t
coverage: '/All files\s*\|\s*(\d{1,3}(?:\.\d+)?)/'
publish:
stage: publish
script:
- echo "//nodejs.repo.asts.com/:_authToken=\"$NPM_AUTH_TOKEN\"" > .npmrc
- npm whoami
- npm publish
我正在尝试从 Gitlab CI 运行ning 在 Docker 中在我的私人 Verdaccio 存储库上发布一个模块。我按照 this tutorial 并在我的主机上生成了令牌(因为将 运行 作业的容器在管道启动之前不存在)。
image: node:11-alpine
stages:
- test
- publish
before_script:
- npm set registry http://nodejs.repo.asts.com
- npm i
test:
stage: test
script:
- npm run lint
- npm t
coverage: '/All files\s*\|\s*(\d{1,3}(?:\.\d+)?)/'
publish:
stage: publish
script:
- echo "//nodejs.repo.asts.com/:_authToken=\"$NPM_AUTH_TOKEN\"" > ~/.npmrc
- cat ~/.npmrc
- npm whoami
- npm publish
作业失败并出现以下错误:
$ npm whoami
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`
但是cat
命令显示令牌具有预期值。
我不明白问题是 Verdaccio 不支持令牌还是我生成它的方式。我也找到了 plugin 但我不知道应该如何使用。
我应该如何配置我的 gitlab CI 以在 Verdaccio 上发布一个包?
它应该像@Hedge 所说的那样工作:将令牌保存在项目文件夹中的 .npmrc
文件中:
image: node:11-alpine
stages:
- test
- publish
before_script:
- npm set registry http://nodejs.repo.asts.com
- npm i
test:
stage: test
script:
- npm run lint
- npm t
coverage: '/All files\s*\|\s*(\d{1,3}(?:\.\d+)?)/'
publish:
stage: publish
script:
- echo "//nodejs.repo.asts.com/:_authToken=\"$NPM_AUTH_TOKEN\"" > .npmrc
- npm whoami
- npm publish