0

I try to follow these steps to add some git commands on TFS 2015 (Update 3) build steps.

For testing, I tried 'git ls-files', that worked.

And then I tried 'git pull'.

It would show:

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

However, Git totally worked well on '_work' folder of TFS server via the local operation.

I already tried many solutions. For me, they didn't work.

I tried to use the Git Build Tools, it was still failed.

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/'

For this issue, I referred this page to add two variables (VSO_GIT_USERNAME & VSO_GIT_PASSWORD) for building scripts. It still didn't work.

I upgraded Git to 2.11.1 and installed GCMW on TFS server.

Moreover, by referring this page, I also typed these commands on TFS server.

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

It still didn't work.

Is there any other suggestion? Thanks a lot.

Community
  • 1
  • 1
Mystic Lin
  • 365
  • 4
  • 15

2 Answers2

1

You dont need to save a username and password. All you need to do is enable the "Allow Scripts to Access OAuth Token" and your build tasks will be able to call back to TFS/VSTS using the build in authentication.

enter image description here

Although this screenshot is from VSTS the option also exists in TFS and has the same name.

enter image description here

Once it has been enabled you can call back to your git repo, or any other TFS resolved without additional authentication.

  • Thanks for your reply. As I described, ''I try to follow [these steps](https://www.visualstudio.com/en-us/docs/build/scripts/git-commands) to add...". So I already "Allow scripts to access OAuth token". That doesn't work for me. Maybe I made something wrong on my TFS server. – Mystic Lin Feb 14 '17 at 15:01
0

Use command below will work:

git pull http://username:password@tfsserver:8080/tfs/teamprojectCollection/_git/GitProject/

Check the screenshot below:

enter image description here

For the password, you can add a variable and keep it secret.

enter image description here

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39