gpt4 book ai didi

docker - 从 Docker gitlab CI 在 Verdaccio 上发布 npm 模块

转载 作者:行者123 更新时间:2023-12-04 11:19:21 27 4
gpt4 key购买 nike

我正在尝试从在 Docker 中运行的 Gitlab CI 在我的私有(private) Verdaccio 存储库上发布一个模块。我关注了this tutorial并且我在我的主机上生成了 token (因为将运行作业的容器在管道启动之前不存在)。

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 命令显示 token 具有预期值。

我不明白问题是 Verdaccio 不支持 token 还是我生成它的方式。我还找到了一个 plugin但我不知道应该如何使用。

我应该如何配置我的 gitlab CI 以在 Verdaccio 上发布一个包?

最佳答案

它应该像@Hedge 所说的那样工作:将 token 保存在项目文件夹中的 .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

关于docker - 从 Docker gitlab CI 在 Verdaccio 上发布 npm 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54552382/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com