It is an authentication issue. You need to get the OAuth token into each of the submodule repos.
Make sure you have the build definition setting enabled to Allow scripts access to the OAuth token. As documented, this stuffs the token into a variable called System.AccessToken. It also stuffs the token into a git config setting that you'll see at the end of your get sources step when you run it after enabling the setting. This is how git authenticates to VSTS. You'll need to build a config statement for each of the repos, and you'll need to cd into that submodule to issue it in that repo.
Here is the Powershell script I used:
$mods = (git submodule status) | % { ($_.Trim() -split " ")[1] }
$baserepo = ($env:BUILD_REPOSITORY_URI).TrimEnd($env:BUILD_REPOSITORY_NAME)
foreach($mod in $mods)
{
cd $mod
$cmd = 'git config http.' + $baserepo + $mod + '.extraheader "AUTHORIZATION: bearer ' + $env:System_AccessToken + '"'
write $cmd
iex $cmd
cd ..
}
Then run a cmd or powershell step:
git submodule update --remote
Lastly, you should clean up the token after you are done with it, so the OAuth doesn't hang out in your .git/config file on your build agent:
$mods = (git submodule status) | % { ($_.Trim() -split " ")[1] }
$baserepo = ($env:BUILD_REPOSITORY_URI).TrimEnd($env:BUILD_REPOSITORY_NAME)
foreach($mod in $mods)
{
cd $mod
$cmd = 'git config --unset-all http.'+ $baserepo + $mod + '.extraheader'
write $cmd
iex $cmd
cd ..
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…