【发布时间】:2018-11-11 10:18:03
【问题描述】:
我正忙于集成 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)。在构建分支和拉取请求(合并)时,我得到以下参数:
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/*,但我不知道从长远来看这是否会导致问题。
【问题讨论】:
-
您目前的解决方法是否遇到任何问题?只需监控它,如果没有问题,这应该是一个很好的解决方法。