使用来自 Gitlab-CI 的部署令牌克隆外部私有子模块

mis*_*iru 8 git-submodules gitlab gitlab-ci

我在私有服务器 serverB 上有一个存储库 repoB,并从中获取部署令牌(用户+密码)。
\n此存储库用作我尝试配置的项目中的子模块。

\n

在这个项目中,我希望能够在 Gitlab-CI 期间初始化这个子模块。

\n

我的.gitmodules是:

\n
[submodule "repoB"]\n    path = repoB\n    url = https://serverB/groupB/repoB.git\n
Run Code Online (Sandbox Code Playgroud)\n

我的.gitlab-ci.yml

\n
test_build:\n    variables:\n        GIT_SUBMODULE_STRATEGY: recursive\n
Run Code Online (Sandbox Code Playgroud)\n

实际上,我得到的错误如下(group:\xc2\xa0 japan7、project: nanachan、repoB: karaneko、serverB git.inpt.fr:)

\n
Updating/initializing submodules recursively...\nSynchronizing submodule url for \'karaneko\'\nCloning into \'/builds/japan7/nanachan/karaneko\'...\nfatal: could not read Username for \'https://git.inpt.fr\': No such device or address\nfatal: clone of \'https://git.inpt.fr/japan7/karaneko.git\' into submodule path \'/builds/japan7/nanachan/karenko\' failed\nFailed to clone \'karaneko\'. Retry scheduled\nCloning into \'/builds/japan7/nanachan/karaneko\'...\nfatal: could not read Username for \'https://git.inpt.fr\': No such device or address\nfatal: clone of \'https://git.inpt.fr/japan7/karaneko.git\' into submodule path \'/builds/japan7/nanachan/karenko\' failed\nFailed to clone \'karaneko\' a second time, aborting\nERROR: failed: exit code 1\n
Run Code Online (Sandbox Code Playgroud)\n

我想我应该将部署令牌用户和密码放在项目机密中(在 Settings\xc2\xa0\xe2\x88\x92>\xc2\xa0CI\xc2\xa0/\xc2\xa0CD\xc2\xa0\xe2\ x88\x92>\xc2\xa0Variables) 但我找不到这些变量的名称,也没有任何帮助来解决这个特殊情况。

\n

我应该如何进行?
\n提前感谢您的帮助!

\n

小智 9

我使用部署令牌解决了同样的问题。刚刚添加了带有部署令牌的子模块,CI 上的一切都运行正常。

http://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git

看起来.gitmodules像:

[submodule "tanuki/awesome_project"]
    path = tanuki/awesome_project
    url = https://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git
Run Code Online (Sandbox Code Playgroud)

https://docs.gitlab.com/ee/user/project/deploy_tokens/

  • 但这确实会暴露超级存储库中的部署令牌,对吧? (17认同)