0

I'm running into problems with a build pipeline I'm defining in Azure DevOps. The issue is similar to what is described in this post but the fix cited isn't working for me. The build job Get Source task runs but the Powershell I have defined is failing because of the agent using a detached HEAD. I'm new to Git and Azure DevOps (lots of experience with SVN and TeamCity/CruiseControl.NET/NANT) so between the different commands and permissions I'm pretty stymied.

I was able to create two test repos and made one a submodule of the other. I built a process that updates the submodule to HEAD using a Powershell task:

Write-Host
Write-Host "RUNNING: git status"
git status

Write-Host
Write-Host "RUNNING: git checkout SubmoduleExperiment"
git checkout SubmoduleExperiment

Write-Host
Write-Host "RUNNING: git submodule update --remote --merge"
git submodule update --remote --merge

Write-Host
Write-Host "RUNNING: git commit -am ""updated submodule"""
git commit -am "updated submodule"

Write-Host
Write-Host "RUNNING: git push"
git push https://$($env:PatForGitPushes):PAT@myTeam.visualstudio.com/MyTeam/_git/my-test HEAD:SubmoduleExperiment

When I apply the same task to my actual project/build, however, it fails because when I git checkout master it tells me I'm behind 'origin/master' by 1 commit even though the detached HEAD is pointing to the same commit as origin/master.

I've set up the Get Source task between my test and the "real" build to be identical. I've set the submodule's URL to use a PAT in both.

Any suggestions on how to fix this situation?

BigPigVT
  • 1,381
  • 3
  • 12
  • 20
  • why do you want to checkout submodules manually? – 4c74356b41 Feb 13 '19 at 15:09
  • 1
    If your goal is to commit and push the repo with the submodule update, during the build process, then you need to navigate to the submodule root, check out the necessary branch (instead of detached), commit, push. At last you go to the repo root, commit and push. – Lex Li Feb 13 '19 at 18:50
  • @LexLi I was under the impression the commands I was doing were equivalent to what you suggest. I don't understand how that would address the issue of the `git checkout master` getting the message I'm seeing, though. Can you help me understand? – BigPigVT Feb 25 '19 at 15:04

0 Answers0