Git submodule fails on TFS Build

后端 未结 2 1069
情深已故
情深已故 2020-12-30 09:50

When I try to build using TFS with Git, there\'s a limitation whereby TFS\'s git provider doesn\'t yet support sub modules. Bit of a pain, but what the heck, I\'m able to te

相关标签:
2条回答
  • 2020-12-30 10:26

    The reason is that 'Git Bash' does not know the credentials of the build account, and it should prompt every time interactively for them. Indeed, if the build account have access to all the submodules remote repo, it just need give empty user name and password for the credential prompt. This is not easy in Windows because the credential manager do not accept empty user name.

    One way to workaround it to change the submodule's URL to something like below. The '@' symbol is same as feeding empty user name and password.

    [submodule "..."]
        path = ...
        url = http://@tfs:8080/...
    
    0 讨论(0)
  • 2020-12-30 10:36

    I've fixed a similar issue after much trial and error: it turned out that this was a problem with the TFS pre-build PowerShell script running with no user profile, and therefore GIT couldn't see the credential cache setting for the build user (e.g. as set in C:\Users\theuser\.gitconfig).

    Batch scripts would suffer from the same issue.

    The distinctive behaviour was that the git submodule calls would hang completely, and would put the GIT repository in a very weird state (as noted by the not a tree errors above).

    The hang is due to GIT prompting for the username and password to use, however this is a non-interactive session, so everything just grinds to a halt.

    Using wincred as credential cache, I was able to fix this by:

    1. Logging onto the build machine as the build user.
    2. Accessing the GIT server via the command line and entered the required credentials.
    3. Opened Windows Credential Manager and checked that the cached credential is visible in the Generic Credentials section.
    4. In elevated command prompt, forced GIT to use wincred by default, even if it has no user config file: git config --system credential.helper wincred
    5. Re-ran the build from TFS: which worked.
    0 讨论(0)
提交回复
热议问题