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

从Docker gitlab CI在Verdaccio上发布npm模块,docker,npm,gitlab,gitlab-ci,verdaccio,Docker,Npm,Gitlab,Gitlab Ci,Verdaccio,我试图从Docker中运行的Gitlab CI在我的私有Verdaccio存储库中发布一个模块。我随后在主机上生成了令牌(因为在管道启动之前,将运行作业的容器不存在) 作业失败,出现以下错误: $ 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

我试图从Docker中运行的Gitlab CI在我的私有Verdaccio存储库中发布一个模块。我随后在主机上生成了令牌(因为在管道启动之前,将运行作业的容器不存在)

作业失败,出现以下错误:

$ 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不支持令牌或我生成令牌的方式。我也找到了一个,但我不知道应该如何使用


我应该如何配置我的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

我没有一个真正的答案,但我知道你可以从哪里开始,问谁,请检查提交者而不是写。npmrc到用户文件夹将其写在你想要发布模块的当前文件夹中。对此也感兴趣@JuanPicado,没有关于Gitlab CI和Verdaccio的官方文档?@Nikita没有,只有插件在我们的GitHub组织中,我可以保证在我们的聊天中提供一些文档或快速帮助。Gitlab是最受欢迎的,我按时贡献,但我不使用它。@JuanPicado感谢您的回复。最后,这比预期的要容易,实际上hedge提供了一个我没有检查的有效解决方案。我将发布一个答案。谢谢,解决方案是将您的答案与对Gitlab受保护标签()的了解不足结合起来。
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