如何解决在合并请求中使用 husky 在 gitlab 上编辑包版本
我想在 Gitlab 上进行合并时编辑我的包版本。我尝试过这样的赫斯基,但它不起作用。
{
"hooks":{
"pre-commit": "npm run lint:fix","post-merge": "(git-branch-is staging && npm version minor || git-branch-is master && npm version major) && git add . && git commit -m \"new version\"",}
}
我像这样尝试使用 Gitlab-CI
enable_merge:
stage: staging_deploy
only:
- staging
script:
- npm version minor
然后我收到一条错误消息
$ npm version minor
v0.5.0
npm ERR! code 128
npm ERR! Command Failed: git commit -m 0.5.0
npm ERR!
npm ERR! *** Please tell me who you are.
npm ERR!
npm ERR! Run
npm ERR!
我不能在本地做,因为分支 staging 和 master 是受保护的
解决方法
由于这是在 CI 中运行,因此 git
可能没有设置其配置,尤其是当您提交时它用于作者的 user.name
和 user.email
。我会在 before_script
步骤中添加这些:
enable_merge:
stage: staging_deploy
only:
- staging
before_script:
- git config --global user.name "Gitlab CI"
- git config --global user.email "an-email-address@example.com"
script:
- npm version minor
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。