在google-repo清单中使用环境变量?

时间:2019-09-12 14:19:48

标签: manifest repo

由于该项目分为多个存储库,因此我们试图在我们的项目中开始使用google-repo。问题是我们的git服务器要求将USERNAME放入URL,例如

git clone ssh://username@git.server.com

但是有可能将其纳入清单吗?我尝试了以下

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
 <remote name="gerrit"
         fetch="ssh://$USER@git.server.com"
         review="ssh://$USER@git.server.com"
         revision="refs/heads/master"/>
 <default remote="gerrit" sync-j="4"/>
 <project name="project" remote="gerrit" path="project"/>
</manifest>

但是google-repo在克隆时仅使用ssh://$USER@git.server.com(也就是说,它不会取消引用环境变量$USER)。

1 个答案:

答案 0 :(得分:1)

这是一个ssh配置问题,您不应在清单的远程添加$ USER。

~/.ssh/config中,添加:

host whatever git.server.com
    IdentityFile ~/.ssh/id_rsa
    User <your_user>

IdentityFile应该链接到您的ssh私钥(YMMV)。

您现在应该可以

git clone ssh://git.server.com