我不能在 fastlane 中使用 push_to_git_remote()

I can't use push_to_git_remote() in fastlane

我对 gitlab、gitlab-ci 和 fastlane 有疑问。在 fastlane 中,我使用的是:

  def increment_build_and_commit
    incrementBuildNumber()
    commit_version_bump(message: 'build number bump [skip ci]')
    push_to_git_remote(
    remote: 'origin_rw',
    remote_branch: ENV['CI_COMMIT_BRANCH']
    )   
  end

所以我想增加内部版本号并提交。所以它通过以下方式完成工作:

incrementBuildNumber(),
commit_version_bump(message: 'build number bump [skip ci]')

但是当 运行 时,它在 push_to_git_remote

处失败

[!] Exit status of command 'git push origin_rw HEAD:HEAD --tags --set-upstream' was 1 instead of 0. error: The destination you provided is not a full refname (i.e., starting with "refs/"). We tried to guess what you meant by:

  • Looking for a ref that matches 'HEAD' on the remote side.
  • Checking if the being pushed ('HEAD') is a ref in "refs/{heads,tags}/". If so we add a corresponding
    refs/{heads,tags}/ prefix on the remote side. Neither worked, so we gave up. You must fully qualify the ref. hint: The part of the refspec is a commit object. hint: Did you mean to create a new branch by pushing to hint: 'HEAD:refs/heads/HEAD'? error: failed to push some refs to '**********.git'

你们中的一些人知道该怎么做以及如何解决这个问题?因为我将成为 google 机器,但不幸的是找不到解决方案。 提前致谢!!

发生这种情况是因为 gitlab-ci checkouts git 提交而不是 git 分支并且您进入分离的 HEAD 状态。

有几种方法可以解决这个问题:

1) 使用 CI 提供的值。 对于 GitLab,我建议使用 CI_PIPELINE_IID。缺点是您无法控制它,如果您将项目迁移到其他存储库,它将再次从 1 开始。

2) 在提交之前检查 git 分支。 缺点是如果其他开发人员推送到同一个分支,您的管道将继续使用错误的源代码。

3) 手动提交版本号。