0

当我在 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 受到保护

4

1 回答 1

0

由于这是在 CI 中运行的,因此git可能没有设置其配置,尤其是在您提交user.nameuser.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
于 2021-02-25T21:01:11.243 回答