2

Issue: Update sub modules from remote via script during CI build

During a CI build script, I want the sub module to be updated to the latest as it is building. I am aware that the build process in VSTS takes care of checking out the sub modules, but they are checked out at the hash reference of whatever is there in the repository. I would like the process to update to the latest code.

The approach I used is as described below.

• I created a command line task in the build pipeline and added the script as below.

git -c http.https://bitbucket.org.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" submodule update --init --force --recursive --remote –merge

• I also checked out check Allow scripts to access OAuth Options in build definition and pass $(System.AccessToken) variable in the command above.

It seems to be the command line script is causing the problem and showing the following error message:

Could not read Username for https://bitbucket.org: terminal prompts disabled.

The build agent is able to execute other git commands such as pulling down the source, checkout the sub modules etc. Sub modules are accessed through https.

• How can I get the authorization done on my command line task??

• Is there any other approach to allow Git Sub modules to pull latest commits?

gangs
  • 21
  • 1

1 Answers1

0

I cannot reproduce it with Bitbucket, but the way I run this from command line task against Azure DevOps Services Git Repo is this:

git config --unset-all http.{organization}@dev.azure.com.extraheader
git -c http.https://{organization}@dev.azure.com.extraheader="AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN" submodule update --init --force --recursive --remote

With Working Directory set to $(Build.SourcesDirectory) and "Allow scripts to access the OAuth token" checked.

My sample .gitmodules file looks like this (I obviously have multiple submodules)

[submodule {submodule}]
    path = {submodule}
    url = https://{organization}@dev.azure.com/{organization}/{project}/_git/{submodule}
    branch = {branch}

I am not sure if that helps, but works in my scenario.