【发布时间】:2019-08-06 16:31:39
【问题描述】:
我们在 Gitlab 中创建了一个 vuejs 库项目,并创建了一个简单的管道,在我们推送提交后执行。
当最后一个作业执行npm version patch(更新项目中的补丁)时我们遇到了问题,但是......它没有更新并且它不起作用。
.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
还有 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 和测试工作正常,但发布没有。
[...]
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
当合并请求被接受时,我们需要自动构建库并使用新版本(新补丁,npm version patch)上传到 npm 存储库。有可能吗?
谢谢。
【问题讨论】:
-
如果可以在 shell 中也可以在 CI 中
标签: node.js docker npm gitlab jenkins-pipeline