gpt4 book ai didi

git - Jenkins Git Refspec 未正确替换分支说明符

转载 作者:太空狗 更新时间:2023-10-29 14:16:43 27 4
gpt4 key购买 nike

我正忙着整合 Jenkins 和 TFS。我第一次不成功的尝试是使用 Jenkins 的多分支管道设置和 TFS。因此,我的第二次尝试是使用带有参数的单个 Jenkins 构建来指定要构建的分支。

我将此参数称为 branchRef 并在“要构建的分支”字段中使用它,例如 ${branchRef}

根据 Team Foundation Server plugin for Jenkins我必须按如下方式指定 Refspec:+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin-pull/* 这将给出我的引用列表如下:

44553f3184c5cbe04e9838209bc752218cd7e54a refs/remotes/origin-pull/563/merge
8bf10538ee29e9df0745ed4b7b23cb20fe56978d refs/remotes/origin/feature/integration
fa8c14671cb6ce1c3ef6dcca52e9e1f45e914e00 refs/remotes/origin/feature/stable

在 TFS 中,我将构建定义设置为使用作业参数,例如:branchRef=$(Build.SourceBranch)。在构建分支和 pull 请求( merge )时,我得到以下参数:

normal branch: refs/heads/integration
pull-request merge: refs/pull/563/merge

这给出了以下 Jenkins 行为

->normal branch
> git.exe rev-parse "refs/remotes/origin/integration^{commit}" # timeout=10
->pull-request
> git.exe rev-parse "refs/pull/563/merge^{commit}" # timeout=10

因此,普通分支 Jenkins/Git 插件正在从 refs/heads/integration 转换为 refs/remotes/origin/integration 而 pull-request 则不会 '翻译”。

我已经实现了一个解决方法,即将 Refspec 更改为:+refs/pull/*:refs/pull/* +refs/heads/*:refs/remotes/origin/* 但我不知道从长远来看这是否会导致问题。

最佳答案

我通过尝试复制您的设置对此进行了测试,并注意到了同样的事情:

So the normal branch Jenkins/Git plugin is translating from refs/heads/integration to refs/remotes/origin/integration while the pull-request it does not 'translate'.

这应该不会在当前状态下引起任何问题(除非更改这种令人困惑的行为),因为每次都应该获取 Remote 。据我所知,如果您没有对 heads 进行任何本地更改,则 refs/heads/integration 成为 refs/remotes/origin/integration 是无关紧要的remotes/origin 被获取。

如果你想绝对确定你可以使用以下方法比较它们:git rev-list --count refs/heads/integration..refs/remotes/origin/integration(它应该是 0 如果它们是相同的)。

The difference between heads and remotes/origin可能与此相关。

关于git - Jenkins Git Refspec 未正确替换分支说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50640603/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com