【发布时间】:2020-12-21 19:01:49
【问题描述】:
我使用 Google CloudBuild 作为 CI 服务器。它使用我的 GitHub 存储库的镜像存储库来检测/提取更改,效果很好。
我的问题是,一旦 CloudBuild 成功运行了我的所有测试,我希望它在我的存储库中添加一个标签。我正在使用gcr.io/cloud-builders/git 容器,但我不能直接推送标签,因为它只连接到镜像仓库。因此,为了解决这个问题,我使用 shell 脚本直接从 Github 克隆 repo 以实际创建标签。
当我尝试从 Cloudbuild 访问 Github 时,我收到以下错误消息:
Step #3: debug1: read_passphrase: can't open /dev/tty: No such device or address
Step #3: Host key verification failed.
Step #3: fatal: Could not read from remote repository.
Step #3:
Step #3: Please make sure you have the correct access rights
Step #3: and the repository exists.
这是我正在使用的脚本(它只是测试 github 访问):
#!bin/sh
# Copy private key to ~/.ssh directory
cp ./path/to/my/key ~/.ssh/github
chmod 600 ~/.ssh/github
# Create SSH config file
cat >~/.ssh/config <<EOL
Host github.com
HostName github.com
AddKeysToAgent yes
IdentityFile ~/.ssh/github
EOL
chmod 600 ~/.ssh/config
# Add key to agent
eval "$(ssh-agent -s)"
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-add -k ~/.ssh/github
# Set GIT config
git config --global user.name "myusername"
git config --global user.email "myusername@users.noreply.github.com"
# Test authentication with Github
ssh -T git@github.com
调试日志的另一个相关部分是:
Step #3: debug1: Reading configuration data /etc/ssh/ssh_config
Step #3: debug1: /etc/ssh/ssh_config line 1: Applying options for github.com
它似乎是从/etc/ssh/ssh_config 读取而不是我创建的~/.ssh/config 文件。
我做错了什么?
【问题讨论】:
标签: git github ssh google-cloud-build