我在Jenkinsfile中使用一个shell脚本来运行数据库迁移。该脚本在设置known_hosts
文件条目后尝试克隆存储库。我正在执行以下操作:
#!/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)的条目到该文件中。这是否会引起问题?