如何配置在pipline中配置git submodule

配置

在.gitlab-ci.yml中配置一个全局变量GIT_SUBMODULE_STRATEGY,告诉runner去下载git子模块。

variables:
  GIT_SUBMODULE_STRATEGY: recursive

出现问题

运行pipeline报了类似错误fatal: could not read Username for 'https://gitlab.com': No such device or address,具体信息如下:

Synchronizing submodule url for 'third_party/third_party_project'
Cloning into '/builds/mind/aiserver/third_party/third_party_project'...
fatal: could not read Username for 'https://gitlab.com': No such device or address
fatal: clone of 'https://gitlab.com/mind/my_project.git' into submodule path '/builds/mind/server/third_party/third_party_project' failed
Failed to clone 'third_party/third_party_project'. Retry scheduled
Cloning into '/builds/mind/server/third_party/third_party_project'...
fatal: could not read Username for 'https://gitlab.com': No such device or address
fatal: clone of 'https://gitlab.com/mind/third_party_project.git' into submodule path '/builds/mind/server/third_party/third_party_project' failed
Failed to clone 'third_party/third_party_project' a second time, aborting

大概意思就是克隆子模块时权限验证错误。

解决办法

在gitlab项目页面Settings > Repository > Deploy Tokens中添加一个Deploy Token
在这里插入图片描述
然后拿到username和token
在这里插入图片描述
配置.gitmodules

[submodule "third_party/third_party_project"]
	path = third_party/third_party_project
	url = https://<username>:<token>@gitlab.com/mind/third_party_project.git

和配置成上图拿到的值。

结语

如果以上方法对你有帮助,就给作者点个赞鼓励一下吧!!!如果有错误或不明白的欢迎留言。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值