Azure DevOps构建

时间:2019-12-28 04:29:59

标签: git azure azure-pipelines

存储库(“网站”)具有子模块(“模板”)。子模块在回购目录中引用。目标是使用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生成的默认初始步骤是检出分支中的文件。因此脚本(例如git rm --cached <pathtomodule>)不能首先运行。

“网站”和“模板”存储库位于同一Azure DevOps项目中。

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

  1. 通过用户界面:

    • “清洁选项”:“所有构建目录”
    • “结帐子模块”:是
    • 分支包括一个.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 add命令之前的PowerShell任务中的submodule update,在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

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

我真的很困惑,感谢任何见解。谢谢。

1 个答案:

答案 0 :(得分:2)

不确定这是否对您有帮助,但是对于已重定位(从存储库中的/ my-submodule移至/ src / my-submodule)的子模块,我一直遇到相同的错误。进行git rm --force /my-submodule,提交并推送到远程可以为我解决此问题。

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