【发布时间】:2018-02-06 19:40:20
【问题描述】:
我正在尝试自动化 Jenkins (atm. 2.60.3, Team Foundation Server Plug-in 5.121.0、git 插件 3.5.1、git 客户端插件 2.5.0) 以及 TFS (15.117.26714.0)
“为所有作业启用推送触发器/所有作业的团队状态”存在于 Jenkins 配置中,当使用测试连接按钮时,soap api 连接确实有效。
我有一个 Multibranch 管道项目,在该 TFS 服务器上配置了一个 git 存储库;我的主要问题是,在扫描 refspec 时找不到拉取请求;我的多分支管道项目中的 refspecs 是:
参考规格
+refs/heads/*:refs/remotes/@{remote}/*
和参考规范
+refs/pull/*:refs/remotes/@{remote}/pull/*
我们从 TFS 2015 更新,如果我没记错的话,参考规范是
+refs/pull/*:refs/remotes/@{remote}/pr/*
使用旧的 2015 TFS,可以找到 pr/refs 并获得像
这样的多分支工作<JENKINSHOST>:8080/job/MultibranchJob/job/pr%252f<PRID>
- 虽然这是几个月前的事了,我还更新了 Jenkins 的 LTS 版本和所有插件。
这反过来将开始验证应该完成的拉取请求是否不会破坏构建。 (据我所知,识别拉取请求尚未在 TFS 插件中实现,如在 bitbucket 和 github 插件中)
@{remote}/pr/* 和 @{remote}/pull/* 似乎都找不到参考规范。 Jenkins 主机有自己编译的 git 版本 2.13.3,因为 Centos 7 git 太旧而无法与 TFS 2017 正常通信。
但是找不到拉取请求参考规范:
Started by user Jenkins admin
[Tue Aug 29 12:49:03 CEST 2017] Starting branch indexing...
> git rev-parse --is-inside-work-tree # timeout=10
Setting origin to MYOWNTFSGITREPO
> git config remote.origin.url MYOWNTFSGITREPO # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --progress origin +refs/pull/*:refs/remotes/origin/pull/* +refs/heads/*:refs/remotes/origin/*
using GIT_ASKPASS to set credentials
> git ls-remote --symref MYOWNTFSGITREPO # timeout=10
using GIT_ASKPASS to set credentials
> git ls-remote MYOWNTFSGITREPO # timeout=10
> git rev-parse --is-inside-work-tree # timeout=10
Setting origin to MYOWNTFSGITREPO
> git config remote.origin.url MYOWNTFSGITREPO # timeout=10
Fetching & pruning origin...
Fetching upstream changes from origin
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --progress origin +refs/pull/*:refs/remotes/origin/pull/* +refs/heads/*:refs/remotes/origin/* --prune
Listing remote references...
> git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials
> git ls-remote -h MYOWNTFSGITREPO # timeout=10
Checking branches...
Checking branch develop
‘Jenkinsfile’ found
Met criteria
Changes detected: develop (51e43e3456f49506086ad5649282695d9f0eff7d → 6008de4da7d017b35cb73cf28963057b8512584c)
Did not schedule build for branch: develop
Checking branch master
‘Jenkinsfile’ found
Met criteria
Changes detected: master (5c2f4df13a6cf53700ff1562d5347c31ff2a8d69 → b856b96743870bc80d9523c79922b01bfe0f363b)
Did not schedule build for branch: master
Checking branch feature/myFeature
‘Jenkinsfile’ found
Met criteria
No changes detected: feature/myFeature (still at 72fa143c6cbf4cf492129ad43f9a0053d5edf785)
Processed 3 branches
[Tue Aug 29 12:49:03 CEST 2017] Finished branch indexing. Indexing took 0.57 sec
Finished: SUCCESS
虽然如果我从我的 dev-pc 使用 git ls-remote:
$ git ls-remote
From MYOWNTFSGITREPO
b856b96743870bc80d9523c79922b01bfe0f363b HEAD
6008de4da7d017b35cb73cf28963057b8512584c refs/heads/develop
72fa143c6cbf4cf492129ad43f9a0053d5edf785 refs/heads/feature/myFeature
b856b96743870bc80d9523c79922b01bfe0f363b refs/heads/master
d6998b37fb29dc5eb6eaac812b8af58e8f31d402 refs/pull/26/merge
是否有可能 --prune 删除了合并,因为它可能无法访问?但是该合并应该在用于拉取请求的两个分支中都有父级,对吗?
我是否遗漏了一些非常明显的东西?
repo 扫描成功,否则找不到其他所有分支。
我知道为拉取请求创建自己的分支有点麻烦,尽管它确实可以验证合并的代码是否有效。如果有更好的方法来实现多分支项目的测试,我绝对愿意采用不同的方法。
编辑:
在我的 dev-pc 上尝试上面日志中的所有命令;最后一个
git ls-remote -h MYOWNTFSREPO
仅限于头部,有没有可能绕过它? git ls-remote MYOWNTFSREPO 也会给我 /refs/pull//merge,这正是我想要开始构建 Pr 合并提交的内容。
【问题讨论】:
-
缩小问题的范围与远程 git 存储库是否在 TFS2017 服务器上保持有关。建议您也尝试一下 GitHub 或 bitbuck 上的其他远程 repos。
-
抱歉,我希望我的编辑能更好地澄清这一点:由于最后一个 git ls-remote 与 -h 一起使用,它只获取 /refs/heads 而不是 /refs/tags 之类的东西(反正我现在不想在这里)也不是 /refs/pull,我的 /refs/pull/
/merge refs 将驻留在哪里;这让我相信它可能与 git 插件或多分支管道插件有关;尽管如此,如果在我必须合并之前有更好的方法来验证 TFS2017 的拉取请求的构建是否正常,我很高兴有任何想法。编辑问题以反映这一点。