【发布时间】:2018-10-31 19:16:01
【问题描述】:
我使用 shell 脚本作为 Jenkinsfile 的一部分来运行数据库迁移。在 known_hosts 文件中设置条目后,shell 脚本会尝试克隆存储库。我正在做以下事情:
#!/bin/bash
set -e
# Workaround old docker images with incorrect $HOME
# check https://github.com/docker/docker/issues/2968 for details
if [ "${HOME}" = "/" ]
then
export HOME=$(getent passwd $(id -un) | cut -d: -f6)
fi
mkdir -p ~/.ssh
echo '
github.com ssh-rsa KEY
' >> ~/.ssh/known_hosts
git clone git@github.com:Organization/migrations.git /tmp/database-migrations
Execute Migration
这给了我一个错误
Permission denied (publickey).
fatal: Could not read from remote repository.
如何解决这个问题?
顺便说一句,当我检查已知主机文件时,我看到一个条目已添加到文件中,其 IP 为192 范围(本地 IP)。这会造成问题吗?
【问题讨论】:
标签: git shell docker jenkins ssh