git - Azure DevOps 构建中出现 "No url found for submodule path in .gitmodules"错误

标签 git azure azure-pipelines

存储库(“网站”)有一个子模块("template")。该子模块在存储库的目录中被引用。目标是使用 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 Overflow 上提出的其他问题类似,但不同之处在于 Azure DevOps 构建中的默认初始步骤是 checkout 分支中的文件。因此脚本(如 git rm --cached <pathtomodule> )不能首先运行。

“网站”和"template"存储库位于同一个 Azure DevOps 项目中。

我尝试了两种方法都没有成功。两者均基于 Microsoft 文档。这是因为我不清楚同一项目的子模块是否可以在不提供显式凭据的情况下包含在存储库中。

  1. 通过用户界面:

    • “清理选项”:“所有构建目录”
    • “ checkout 子模块”:True
    • 分支包含 .gitmodule 文件:True
  2. 通过 PowerShell 任务中的 git 命令:

尝试了两者的变体:

$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
  • 在没有 .gitmodules 文件的分支和有 .gitmodules 文件的分支上都未成功测试构建。
  • 在 Bash 和(稍作调整)PowerShell 中测试构建任务均未成功。
  • 未能成功测试 Azure DevOps 存储库 URL 的各种结构(例如 https://organization.visualstudio.com/project/_git/repohttps://$(PAT)@organization.com.visualstudio.com:/project/_git/template 等)。

尝试的其他内容是上述内容的变体,其中包括 git submodule addsubmodule update 之前的 PowerShell 任务中命令,正在运行ls -lR在 Bash 任务中调查是否下载了子模块文件(即使文件丢失,构建任务有时也会指示成功)以及 .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

...以及更多加上所有各种组合。没有一个成功。

我真的陷入困境并感谢任何见解。谢谢。

最佳答案

不确定这是否有帮助,但是对于重新定位的子模块(从存储库中的/my-submodule 移动到/src/my-submodule ),我一直在努力解决相同的错误。做git rm --force /my-submodule ,提交并推送到远程为我解决了这个问题。

我发现使用git submodule status有助于本地检查子模块状态是否正确。我尝试后git rm它停止报告错误“致命:在 .gitmodules 中找不到子模块路径 'my-submodule' 的 url”

关于git - Azure DevOps 构建中出现 "No url found for submodule path in .gitmodules"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59508121/

相关文章:

ruby-on-rails - Capistrano 无法从非主分支部署

azure - 如何在 Azure 门户中以最新的方式列出 blob 文件

tfs - 在构建过程中修改 TFS 2015 BuildNumber

testing - 在Azure Pipelines上执行Visual Studio测试任务: Updating DontShowUI to 1 failed due to exception

Azure DevOps : Model Register and package through Azure CLI in Devops pipeline Task

azure - 如何在“删除文件”任务中从删除中排除某些目录和文件

git - 如何使用heroku查看整个提交历史?

git - 具有相关历史的部分 git 克隆

android - 从 Eclipse 恢复已删除的 Git 存储库

azure - ffmpeg:对速度的需要