在Travis文档中的“设置”标签页中有一个“SSH密钥”,但在我的账户中没有。我需要添加SSH密钥以克隆GitHub上的子模块。
在travis-ci.com(付费计划)上,使用SSH密钥仅适用于私有存储库。
使用travis
命令行工具,您可以生成新的SSH密钥,该密钥将设置在Travis CI和您的GitHub用户帐户上(如果您为Travis CI使用专用GitHub用户)。
以下是必要的控制台命令:
# Install Travis command line tool
gem install travis
# Login to Travis Pro (private repositories) account
travis login --pro
# Generate and setup SSH key for your GitHub repository
travis sshkey --generate -r organization/repository
不必使用travis
生成新的SSH密钥,也可以通过以下方式上传现有的SSH密钥:
travis sshkey --upload "C:\my_keys\id_rsa" -r organization/repository
创建SSH密钥后,建议从Travis用户的.ssh目录中的config文件引用此密钥。您可以通过将以下行添加到您的.travis.yml来实现这一点:
# http://docs.travis-ci.com/user/build-lifecycle/
before_script:
- echo -e "Host github.com\n\tHostName github.com\n\tUser git\n\tIdentityFile ~/.ssh/id_rsa\n" >> ~/.ssh/config
如需了解更多信息,请访问官方文档:生成新密钥。
目前此功能仅适用于私有存储库。
对于公共存储库,你不需要它们成为私有 Git URL(假设它们在 GitHub 上),所以将 URL 更改为使用公共克隆 URL 就可以解决问题。