似乎使用拉取请求需要两个遥控器来跟踪两者的构建结果(至少当上游遥控器被删除时我没有在 PR 上获得结果)
使用当前的 4.0.13 测试版(和 .12 测试版)我尝试通过直接拉取来解决它,但是直接使用时存在一个影响当前版本计算的错误(https://github.com/GitTools/GitVersion/issues/第1390章)
我目前的解决方法是在之前删除上游远程:
def remotes = bat(script: "@call git remote show", returnStdout: true).trim().readLines()
def hasUpstream = remotes.any { it == "upstream" }
def upstreamURL
if (hasUpstream) {
echo "Remote 'upstream' detected -- ${env.BRANCH_NAME} is pull request, removing remote for further processing"
upstreamURL = bat(script: "@call git remote get-url upstream", returnStdout: true).trim()
bat "git remote remove upstream"
}
然后执行:
def command = "@call ${BuildInfo.GitVersion.Run} /updateassemblyinfo /ensureassemblyinfo /nofetch /verbosity debug"
def output = bat(script: command, returnStdout: true).trim()
并在之后添加回来:
if (hasUpstream) {
echo "Restoring 'upstream' remote using url: ${upstreamURL}"
bat "git remote add -t master --tags upstream ${upstreamURL}"
}