0

除了作业正在运行的分支之外,我一直在尝试找到分支源配置以至少获取远程分支develop,但成功率为零。master

我的用例是根据 git ref 名称确定版本并使用 GitVersion 提交消息。到目前为止,我发现的唯一解决方法是麻烦且不可移植,因为它需要在不针对本地( file:// )存储库运行时向 git cli 提供凭据。

sh "git fetch origin master:master"
sh "git fetch origin develop:develop"

我将不得不编写一个自定义以GitSCMExtension获得这种行为吗?

4

1 回答 1

0

看起来远程分支( origin/{branch} )的 refs 实际上已被获取,只有没有匹配的本地跟踪分支( origin/{branch} -> {branch} )被创建,这会导致 GitVersion 关闭。似乎它产生的错误消息直接与此默认配置相矛盾:

System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.

在https://github.com/GitTools/GitVersion/issues/1049#issuecomment-585878737找到解决方案

这是配置 GitVersion 以实际考虑 /origin/master 和 /origin/develop

  develop:
    # (..)
    regex: (^dev(elop)?(ment)?$|^origin\/dev(elop)?(ment)?$)
  master:
    # (..)
    regex: (^master$|^origin\/master$)
于 2020-12-07T14:27:30.773 回答