gpt4 book ai didi

git - 如何启用我的 Azure 管道以使用 Git checkout 子模块?

转载 作者:行者123 更新时间:2023-12-03 23:03:01 25 4
gpt4 key购买 nike

在我们的 Git 项目中,我们在 .gitmodules 中定义了以下内容

[submodule "DBPkg"]
path = DBPkg
url = https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b1fcd0d8dff2def1d5d4c79fd0cbc4c3d49fd2dedc" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg

构建 Azure Pipeline 时,在“获取源”管道步骤(我使用“Azure Repos Git”)中,我启用了子模块的 check out

enter image description here

在我们的项目设置中,我还做了以下配置...

enter image description here

但是,在构建项目时,尝试使用以下内容 check out 子模块时它会死掉......

2020-10-16T20:29:44.9912145Z HEAD is now at e06abce Modified docker file to remove unnecessary container name.
2020-10-16T20:29:44.9913415Z ##[command]git submodule sync
2020-10-16T20:29:44.9920288Z ##[command]git -c http.https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c715d55527f537c58594a125d46494e59125f5351125944484e5d54595d58594e" rel="noreferrer noopener nofollow">[email protected]</a>="AUTHORIZATION: bearer ***" submodule update --init --force
2020-10-16T20:29:44.9923206Z Submodule 'DBPkg' (https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a173b333419351a3e3f2c743b202f283f74393537" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg) registered for path 'DBPkg'
2020-10-16T20:29:44.9923842Z Cloning into '/home/vsts/work/1/s/DBPkg'...
2020-10-16T20:29:44.9924246Z remote: TF401019: The Git repository with name or identifier DBPkg does not exist or you do not have permissions for the operation you are attempting.
2020-10-16T20:29:44.9924850Z fatal: repository 'https://dev.azure.com/MainCo/OurProject/_git/DBPkg/' not found
2020-10-16T20:29:44.9925716Z fatal: clone of 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8f5d9d1d6fbd7f8dcddce96d9c2cdcadd96dbd7d5" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg' into submodule path '/home/vsts/work/1/s/DBPkg' failed
2020-10-16T20:29:44.9926288Z Failed to clone 'DBPkg'. Retry scheduled
2020-10-16T20:29:44.9926718Z Cloning into '/home/vsts/work/1/s/DBPkg'...
2020-10-16T20:29:44.9927132Z remote: TF401019: The Git repository with name or identifier DBPkg does not exist or you do not have permissions for the operation you are attempting.
2020-10-16T20:29:44.9928020Z fatal: repository 'https://dev.azure.com/MainCo/OurProject/_git/DBPkg/' not found
2020-10-16T20:29:44.9928801Z fatal: clone of 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="367b575f5875597652534018574c4344531855595b" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg' into submodule path '/home/vsts/work/1/s/DBPkg' failed
2020-10-16T20:29:44.9929412Z Failed to clone 'DBPkg' a second time, aborting

我还需要做什么才能授予管道步骤 check out 子模块的权限? .gitmodules 中的 URL 是直接从 Repos 部分剪切并粘贴的,我们通常会在其中克隆该存储库。

编辑:从门户复制的问题中存储库的 URL 为

https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ad7fbf3f4d9f5dafeffecb4fbe0efe8ffb4f9f5f7" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/MainAPIs
https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="703d11191e331f301415065e110a0502155e131f1d" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg

因此子模块位于 https://[email protected]/MainCo/OurProject/_git/DBPkg 但不确定如何用 Git 子模块来表达上述内容。

编辑2:

针对给出的答案,这里是代理报告的错误输出......

...
2020-10-20T13:21:23.9543308Z ##[command]git submodule sync
2020-10-20T13:21:23.9892501Z ##[command]git -c http.https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c984a8a0a78aa689adacbfe7a8b3bcbbace7aaa6a4e7acb1bdbba8a1aca8adacbb" rel="noreferrer noopener nofollow">[email protected]</a>="AUTHORIZATION: bearer ***" submodule update --init --force
2020-10-20T13:21:24.0147532Z Submodule 'DBPkg' (https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e3ae828a8da08ca3878695cd8299969186cd808c8e" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg) registered for path 'DBPkg'
2020-10-20T13:21:24.0194148Z Cloning into '/home/vsts/work/1/s/DBPkg'...
2020-10-20T13:21:24.1694357Z remote: TF401019: The Git repository with name or identifier DBPkg does not exist or you do not have permissions for the operation you are attempting.
2020-10-20T13:21:24.1696067Z fatal: repository 'https://dev.azure.com/MainCo/OurProject/_git/DBPkg/' not found
2020-10-20T13:21:24.1726598Z fatal: clone of 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f426e66614c604f6b6a79216e757a7d6a216c6062" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg' into submodule path '/home/vsts/work/1/s/DBPkg' failed
2020-10-20T13:21:24.1731117Z Failed to clone 'DBPkg'. Retry scheduled
2020-10-20T13:21:24.1760958Z Cloning into '/home/vsts/work/1/s/DBPkg'...
2020-10-20T13:21:24.3885945Z remote: TF401019: The Git repository with name or identifier DBPkg does not exist or you do not have permissions for the operation you are attempting.
2020-10-20T13:21:24.3892068Z fatal: repository 'https://dev.azure.com/MainCo/OurProject/_git/DBPkg/' not found
2020-10-20T13:21:24.3902720Z fatal: clone of 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5419353d3a173b143031227a352e2126317a373b39" rel="noreferrer noopener nofollow">[email protected]</a>/MainCo/OurProject/_git/DBPkg' into submodule path '/home/vsts/work/1/s/DBPkg' failed
2020-10-20T13:21:24.3909036Z Failed to clone 'DBPkg' a second time, aborting
2020-10-20T13:21:24.3987155Z ##[error]Git submodule update failed with exit code:

1

最佳答案

更新2

管道可以访问授权项目中的任何 Azure DevOps 存储库,如前面的将作业授权范围限制为当前项目部分中所述,除非启用了将作业授权范围限制为引用的 Azure DevOps 存储库

启用此选项后,您可以将所有管道的访问范围缩小到仅由使用该存储库的管道作业中的 checkout 步骤明确引用的 Azure DevOps 存储库。

尝试关闭此选项并再次检查。

如果还是不行,你需要检查repo的安全性。找到您的[项目名称]构建服务帐户和项目集合构建服务帐户,确保它们都有足够的权限来访问您的两个git存储库。

enter image description here

<小时/>

更新

尝试在 .gitmodules 中使用它,因为子模块 repo 与父模块位于相同的 url 中。 :

[submodule "DBPkg"]
path = DBPkg
url = ../DBPkg

您还可以查看此链接:https://stackoverflow.com/a/34618962/5391065

<小时/>

The build pipeline will check out your Git submodules as long as they are:

  • Unauthenticated: A public, unauthenticated repo with no credentialsrequired to clone or fetch.

  • Authenticated:

    1. Contained in the same project, GitHub organization, or BitbucketCloud account as the Git repo specified above.

    2. Added by using a URL relative to the main repository. For example, this one would be checked out: git submodule add /../../submodule.git mymodule This one would not be checked out: git submodule add https://dev.azure.com/fabrikamfiber/_git/ConsoleApp mymodule

您还可以查看 Azure DevOps 文档 here .

类似的博客供您引用:Using Git submodules in (private) Azure DevOps repositories

关于git - 如何启用我的 Azure 管道以使用 Git checkout 子模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64396286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com