Drupal Commerce, TeamCity and Git Submodules

At Headscape we use TeamCity as our Continuous Integration server and I recently came across an error when trying to build Drupal Commerce Kickstart.

The main parts of the error message were

Failed to build patch for build... due to error: 'build patch' command failed.

stderr: The repository  has a submodule in the commit '77b28273d1ebb08fd03ee254bbb20b6b476d16ec' at a path 'profiles/commerce_kickstart/libraries/jquery.bxslider', but has no .gitmodules configuration at the root directory

To fix this I needed a list of the submodules which I found using a command given in this Stack Overflow thread

$ git ls-files --stage | grep 160000

This listed the submodules as

160000 49a59494c0769c67a7ed2afe35f096e6d6fc956d 0 profiles/commerce_kickstart/libraries/jquery.bxslider<br /> 160000 9b8da2340b87e8dbbb5e7e2563a2ca4bdf09a1b4 0 profiles/commerce_kickstart/libraries/jquery_expander<br /> 160000 bd879003043b4a93b78cbd4a582b6e0650900bcb 0 profiles/commerce_kickstart/libraries/jquery_ui_spinner<br /> 160000 538237c7c5e95736fc376f4efc3e40f5b98eecc5 0 profiles/commerce_kickstart/libraries/selectnav.js

The next step is to find the remote URL for each of them. After moving into the directory

$ cd profiles/commerce_kickstart/libraries/jquery.bxslider

I then used $ git remote show origin

Which returns Fetch URL: https://github.com/stevenwanderski/bxslider-4.git

Each of these needs adding to the .gitmodules file as a submodule so we end up with the .gitmodules file looking like this

[submodule "profiles/commerce_kickstart/libraries/jquery.bxslider"]<br /> path = profiles/commerce_kickstart/libraries/jquery.bxslider<br /> url = https://github.com/stevenwanderski/bxslider-4.git

[submodule “profiles/commerce_kickstart/libraries/jquery_expander”]
path = profiles/commerce_kickstart/libraries/jquery_expander
url = https://github.com/kswedberg/jquery-expander.git

[submodule “profiles/commerce_kickstart/libraries/jquery_ui_spinner”]
path = profiles/commerce_kickstart/libraries/jquery_ui_spinner
url = https://github.com/btburnett3/jquery.ui.spinner.git

[submodule “profiles/commerce_kickstart/libraries/selectnav.js”]
path = profiles/commerce_kickstart/libraries/selectnav.js
url = https://github.com/lukaszfiszer/selectnav.js.git

Once this file has been committed TeamCity was able to complete the build.