回购(“网站”)有一个子模块(“模板”)。子模块在回购程序的目录中引用。目标是使用Azure DevOps管道一起构建回购模块和子模块。但是,Azure DevOps构建会引发以下错误:
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
根据对.gitmodule
文件的调整,还引发此错误:
fatal: no submodule mapping found in .gitmodules for path '<repo directory AKA "website">/<submodule directory AKA "template">'
.这个问题类似于在Stack溢出上问到的其他问题,但区别在于Azure DevOps构建中的默认初始步骤是签出分支中的文件。因此,不能先运行脚本(如git rm --cached <pathtomodule>
)。
“网站”和“模板”repos位于相同的Azure DevOps项目中。
我尝试过两种方法,但都没有成功。两者都是基于Microsoft文档的。这是因为我不清楚来自同一个项目的子模块是否可以包含在回购中,而不需要提供明确的凭据。
通过用户界面的
- "Clean options": "All build directories"
- "Checkout submodules": True
- Branch includes a .gitmodule file: True
两种尝试过的变体:
$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
和
git -c http.https://dev.azure.com/organization/project/_git/template.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" submodule update --init --recursive
https://organization.visualstudio.com/project/_git/repo
、https://$(PAT)@organization.com.visualstudio.com:/project/_git/template
等)。其他尝试过的变化包括git submodule add
命令之前的PowerShell任务中的ls -lR
,在Bash任务中运行ls -lR
来调查是否下载了子模块文件(构建任务有时表示成功,即使文件丢失了),以及.gitmodules文件的无休止的变化。
正如.gitmodules现在所做的那样(失败):
[submodule "template"]
path = <repo directory AKA "website">/<submodule directory AKA "template">
url = https://dev.azure.com/organization/project/_git/template
这些变化包括:
[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更多加上所有不同的组合。没有一个是成功的。
我真的被困住了,欣赏任何洞察力。谢谢。
发布于 2020-04-15 06:48:13
这里不确定这是否有帮助,但对于被重新定位的子模块(从/my-子模块移到存储库中的/src/my-子模块),我遇到了相同的错误。执行git rm --force /my-submodule
,提交并推动远程解决了这个问题。
我发现使用git submodule status
有助于本地检查子模块状态是否正确。在我尝试git rm
之后,它停止报告错误“.gitmodules中的子模块路径‘my-子模块’没有找到url”。
发布于 2021-11-29 09:03:26
FWIW,在我的示例中,我在选择一个对.gitmodules
文件进行更改的提交时遇到了这条错误消息(并在其中创建了一个合并冲突)。解决方案是先完成樱桃采摘,然后错误信息消失了。
发布于 2021-10-27 18:47:38
在我的例子中,Visual使用如下的相对路径将子模块项目添加到解决方案中:"..\MySubModuleProject\MySubmoDuleProject.csproj“,即使解决方案中的其他项目被引用如下:"MyOtherProjects\MyOtherProjects.csproj”。这个无效引用的工作原理是没有道理的,但是删除..\解决了这个问题。它在本地工作,并且修复了构建管道中的问题,在那里它找不到项目,因为解决方案错误地在一个目录上查找它。
下面是我的yml步骤:
steps:
- checkout: self
submodules: true
persistCredentials: true
path: ''
clean: true
这是我的.gitmodules文件:
[submodule "MySubModuleProject"]
path = MySubModuleProject
url = ../MySubModuleProject
branch = main
这个子模块项目与引用它的解决方案位于相同的Azure项目空间中,这就是为什么我们使用./MySubModuleProject来查找它的原因。
https://stackoverflow.com/questions/59508121
复制相似问题