CI脚本中的NPM CLI身份验证(Bitbucket管道)

时间:2018-08-22 12:29:05

标签: npm continuous-integration bitbucket-pipelines

因此,我尝试在合并到我的仓库master中时自动将软件包发布到NPM。根据{{​​3}}的提示,脚本如下所示:

pipelines: default: ... branches: master: - step: name: Build, test, bump version, tag commit and publish caches: - node script: - yarn - yarn build - yarn test - git init - git config user.email "my@email.com" - git config user.name "My Name" - git config push.default simple - git remote set-url origin ssh://git@bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}.git - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc - yarn versionbump:patch - git show-ref - git push --follow-tags - yarn npmpublish


还有我在scripts中的package.json

"npmpublish": "npm publish", "versionbump:patch": "npm version patch -m '[skip CI] Update to %s'",

我已经在回购环境变量中设置了NPM_TOKEN,可从www.npmjs.com-个人资料-令牌中获取

一切正常,直到 publish为止,但失败: npm ERR! code ENEEDAUTH npm ERR! need auth auth required for publishing npm ERR! need auth You need to authorize this machine using `npm adduser`

然后我尝试使用here来发布,同时保留printf ...命令,然后错误提示ci-publish时已经设置了身份验证令牌正在尝试设置身份验证。不幸的是,删除printf命令并使用ci-publish失败,并显示完全相同的错误,提示需要auth。

如何在Bitbucket管道中验证NPM CLI?

谢谢:-)

0 个答案:

没有答案