Search code examples
gittfsoauthtfs-2015

Run Git commands on TFS 2015 build steps was failed


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.


Solution

  • 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