在TFS 2015上运行Git命令构建步骤失败

问题描述:

我尝试按照these steps在TFS 2015(更新3)构建步骤中添加一些git命令。在TFS 2015上运行Git命令构建步骤失败

为了测试,我尝试了'git ls-files',工作。

然后我尝试'git pull'。

它会显示:

2017-02-09T03:23:36.7164903Z git pull 
2017-02-09T03:23:36.7164903Z Error message highlight pattern: 
2017-02-09T03:23:36.7164903Z Warning message highlight pattern: 
2017-02-09T03:23:36.9660887Z bash: /dev/tty: No such device or address 
2017-02-09T03:23:36.9660887Z error: failed to execute prompt script (exit code 1) 
2017-02-09T03:23:36.9660887Z fatal: could not read Username for 'http://htwb0228:8080': Invalid argument 

然而,完全的Git上TFS服务器的 '_work' 文件夹通过本地操作行之有效。

我已经尝试了很多解决方案。对我来说,他们没有工作。

我试图使用Git Build Tools,它仍然失败。

2017-02-09T01:53:41.3965148Z git pull 
2017-02-09T01:53:41.3965148Z Error message highlight pattern: 
2017-02-09T01:53:41.3965148Z Warning message highlight pattern: 
2017-02-09T01:53:42.4729079Z fatal: Authentication failed for 'http://OAuth:********@htwb0228:8080/tfs/DefaultCollection/KKKKK/_git/PPPP/' 

对于这个问题,我提到this page用于构建脚本添加两个变量(VSO_GIT_USERNAME & VSO_GIT_PASSWORD)。它仍然没有工作。

我将Git升级到2.11.1,并在TFS服务器上安装了GCMW

此外,通过引用this page,我也在TFS服务器上键入这些命令。

git config --global credential.http://htwb0228:8080.integrated true 
git config --global credential.http://htwb0228.integrated true 
git config --global credential.htwb0228.integrated true 
git config --global credential.integrated true 

它仍然没有工作。

有没有其他建议?非常感谢。

使用以下命令将工作:

git pull http://username:[email protected]:8080/tfs/teamprojectCollection/_git/GitProject/ 

检查下面的截图:

enter image description here

对于密码,您可以添加一个变量,并保守秘密。

enter image description here

+0

解决构建团队提供的OOB解决方案的一个非常简单的问题是一个很长的路要走。 –

你不需要保存用户名和密码。您只需启用“允许脚本访问OAuth令牌”,您的构建任务就可以使用内置身份验证回拨到TFS/VSTS。

enter image description here

虽然这个截图是从VSTS选项也存在于TFS并具有相同的名称。

enter image description here

一旦它被激活,您可以打电话回你的混帐回购协议,或任何其他TFS无需额外的认证解决。

+0

感谢您的回复。正如我所描述的,'我尝试按照[这些步骤](https://www.visualstudio.com/en-us/docs/build/scripts/git-commands)添加...“。所以我已经“允许脚本访问OAuth令牌”。这对我不起作用。也许我在我的TFS服务器上犯了错误。 –