我有一个依赖于其他一些 repo 的 repo 。
我正在尝试使用 gitlab-runner 将辅助存储库克隆到 Windows 机器上。
我的 gitlab-ci.yml
看起来像这样:
# Deploy to a staging server
deploy_staging:
stage: deploy
tags:
- my_gitlab_runner
script:
- echo "Deploy to staging server"
- cd C:/
- git clone git@gitlab.com:test_group/test_ci
environment:
name: staging
url: https://127.0.0.1
only:
- master
如果我登录到 windows 框 - 我可以使用 git bash 手动克隆 repos(我已经在 C:/Users/myusername/.ssh
中设置了我的 ssh 设置)我的 .ssh 配置如下所示:
Host gitlab.com
Hostname altssh.gitlab.com
user git
Port 443
PreferredAuthentications publickey
IdentityFile C:/git_keys/my_gitlab_rsa
我必须使用端口 443 - 它在通过 gitbash 进行时可以正常工作。作业不断失败并出现以下错误:
Cloning into 'test_ci'...
Host key verification failed.
fatal: Could not read from remote repository.
我添加了我的 my_gitlab_rsa.pub
作为 deploy_key 到 repo - 它适用于本地克隆 - 只是不通过 gitlab-runner。我的 gitlab-runner 的 config.toml 如下所示:
[[runners]]
name = "TestDesktop"
url = "https://gitlab.com"
token = "_yt...32fjJb"
tls-ca-file = "C:/my_certs/my_self_signed_ca.pem"
executor = "shell"
shell = "cmd"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
有任何想法吗?
最佳答案
这只是部分答案,但回答了我提出的问题!
它归结为known_hosts
文件。
当我以本地用户身份运行它时,它会要求我验证指纹 - 它会将其添加到 known_hosts
文件。
我刚刚复制/粘贴了 known_hosts
文件从我的本地用户到系统帐户.ssh
目录,然后作业成功而没有问题。
就是说-我不确定自动化的最佳方法-因为我不想每次都必须先以本地用户身份手动运行它才能“接受指纹”-但我想这主要回答了我的问题。
关于Windows 上的 gitlab-runner 没有获得 .ssh 配置设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64436999/