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:
fatal: No url found for submodule path '<repo directory AKA "website">/<submodule directory AKA "template">' in .gitmodules
[error]Git submodule update failed with exit code: 128
Depending on adjustments to the .gitmodule
file, this error is also thrown:
fatal: no submodule mapping found in .gitmodules for path '<repo directory AKA "website">/<submodule directory AKA "template">'
.
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.
Via the UI:
- "Clean options": "All build directories"
- "Checkout submodules": True
- Branch includes a .gitmodule file: True
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
- Unsuccessfully tested builds on both on a branch without a .gitmodules file and on a branch with a .gitmodules file.
- Unsuccessfully tested build tasks in both Bash and (slightly adjusted for) PowerShell.
- Unsuccessfully tested the various constructions of Azure DevOps repo URLs (like
https://organization.visualstudio.com/project/_git/repo
,https://$(PAT)@organization.com.visualstudio.com:/project/_git/template
, etc.).
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:
[submodule "<repo directory AKA 'website'>/template"]
path = D:\\a\\1\\s\\<repo directory AKA "website">\\<submodule directory AKA "template">
path = $env:Build.SourcesDirectory/template
url = ../project/_git/template
...and more plus all the various combinations. None are successful.
I am truly stuck and appreciate any insight. Thank you.