Search code examples
manifestrepo

Use environment variables inside google-repo manifest?


We are trying to start using google-repo in our project as the project is divided into multiple repositories. The problem is that our git server requires that one puts the username into the URL, e.g.

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

But is it possible to get that into the manifest? I've tried the following

<?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>

but google-repo simply uses ssh://$USER@git.server.com when cloning (that is, it does not dereference environment variable $USER).


Solution

  • This is a ssh config issue, you should not add $USER in the remote of your manifest.

    In ~/.ssh/config, add:

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

    IdentityFile should link to your ssh private key (YMMV).

    You should now be able to

    git clone ssh://git.server.com