hcdocs
hcdocs

Reputation: 1309

"No url found for submodule path in .gitmodules" error in Azure DevOps build

A repo ("website") has a submodule ("template"). The submodule is referenced inside a directory of the repo. The goal is to use an Azure DevOps pipeline to build the repo and submodule together. However, the Azure DevOps build throws the following errors:

Depending on adjustments to the .gitmodule file, this error is also thrown:

This question is similar to others asked on Stack Overflow, but the difference is that the default initial step in Azure DevOps builds is to check out files in the branch. So scripts (like git rm --cached <pathtomodule>) cannot be run first.

The "website" and "template" repos are in the same Azure DevOps project.

I have tried two ways unsuccessfully. Both are based on Microsoft documentation. This is because it's unclear to me whether a submodule from the same project can be included in a repo without providing explicit credentials.

  1. Via the UI:

    • "Clean options": "All build directories"
    • "Checkout submodules": True
    • Branch includes a .gitmodule file: True
  2. By git command in a PowerShell task:

Tried variations of both:

$AUTH=$(echo -n ":$(PAT)" | openssl base64 | tr -d '\n')
git -c http.https://dev.azure.com/organization/project/_git/template.extraheader="AUTHORIZATION: basic $AUTH" clone https://dev.azure.com/organization/project/_git/template --no-checkout --branch master

and

git -c http.https://dev.azure.com/organization/project/_git/template.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" submodule update --init --recursive

Other things tried are variations of the above that include git submodule add in the PowerShell task before the submodule update command, running ls -lR in a Bash task to investigate whether the submodule files downloaded (the build task sometimes indicates success even though the files are missing), and endless variations of the .gitmodules file.

As .gitmodules stands now (unsuccessfully):

[submodule "template"]
    path = <repo directory AKA "website">/<submodule directory AKA "template">
    url = https://dev.azure.com/organization/project/_git/template

Variations include things like:

...and more plus all the various combinations. None are successful.

I am truly stuck and appreciate any insight. Thank you.

Upvotes: 9

Views: 23740

Answers (2)

Raven
Raven

Reputation: 3526

FWIW, in my case I encountered this error message while I was cherry-picking a commit that made changes to the .gitmodules file (and which created a merge conflict in it). The solution was to first finish the cherry-pick and afterwards the error message was gone.

Upvotes: 2

andyandy
andyandy

Reputation: 948

Not sure if this helps here, but I've struggled with the same error for a submodule that was relocated (moved from /my-submodule to /src/my-submodule in the repository). Doing git rm --force /my-submodule, commit and push to remote resolved the issue for me.

I found that using git submodule status is helpful to locally check whether the submodule state is correct or not. After I tried git rm it stopped reporting the error "fatal: No url found for submodule path 'my-submodule' in .gitmodules"

Upvotes: 17

Related Questions