[英]Gitlab - Update version package
We created a vuejs library proyect in Gitlab and created a simple pipelines that excecuted after when we pushed the commit. 我们在Gitlab中创建了一个vuejs库proyect,并创建了一个简单的管道,该管道在我们推送提交后执行。
We have a problem when last job execute the npm version patch
(that update the patch in the project) but... it's not updated and it's doesn't work. 我们在上一个作业执行
npm version patch
(在项目中更新补丁)时遇到问题,但是...未更新,因此无法正常工作。
.gutlab-ci.yml .gutlab-ci.yml
image: node:8.10.0-slim
cache:
paths:
- node_modules/
before_script:
- npm install
stages:
- lint
- test
- deploy
test:
stage: test
script:
- npm run peers:add && npm run test:unit
tags:
- docker
lint:
stage: lint
script:
- npm run lint
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
publish:
stage: deploy
script:
- npm run peers:remove
- echo -e "//gitlab.com/api/v4/projects/<my-project>/packages/npm/:_authToken=${CI_NPM_TOKEN}" > ~/.npmrc
- npm login
- npm version patch
- npm publish
And package.json 还有package.json
[...]
"scripts": {
...
"build:dev": "npm run clean && webpack --config build/webpack.config.dev.js",
"version": "npm run build:dev && git add -A dist",
"postversion": "git push --follow-tags"
...
}
[...]
Jobs lint and test working but the publish not. 乔布斯不屑一顾并测试工作正常,但不发布。
[...]
removed 4 packages in 9.428s
$ echo -e "//gitlab.com/api/v4/projects/<my-project>/packages/npm/:_authToken=${CI_NPM_TOKEN}" > ~/.npmrc
$ npm login
Username: npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/...-debug.log
ERROR: Job failed: exit code 1
We need when the Merge Request it's accepted, automatically builed library and upload to npm repository with a new version (new patch, npm version patch
). 当合并请求被接受时,我们需要自动构建库并使用新版本(新补丁,
npm version patch
)将其上传到npm存储库。 It's possible? 这是可能的?
Thx. 谢谢。
npm login
is an interactive command so doesn't work in CI very well. npm login
是一个交互式命令,因此在CI中效果不佳。 Try using the package npm-login-noninteractive
to pass your credentials via command line. 尝试使用软件包
npm-login-noninteractive
通过命令行传递您的凭据。 You can install it globally in your before_script: 您可以在before_script中全局安装它:
before_script:
- npm i -g npm-login-noninteractive
Then call it in place of npm login
in your publish script. 然后在发布脚本中代替
npm login
调用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.