我正在尝试设置 Gitea 和 Jenkins 在单独的 Docker 容器中运行并设置一个简单的管道。
我遇到的问题是将 Jenkins 连接到 Gitea。在我的设置中,Gitea 在容器的 22 端口上侦听 SSH,我将其映射到本地主机上的 3001 端口(目前用于测试目的)。
在创建新的管道接口中,我被要求将 SSH url 提供给 Gitea 存储库。我确实提供了这个:
git@localhost:3001/repo/project.git
但似乎 Jenkins 无法连接说我需要一个有效的 URL。我已经将 Jenkins 生成的密钥添加到我的 Git 用户配置文件中。
然后我尝试从我的本地主机进行 git clone,所以我生成了一对密钥,将公钥添加到同一个 Git 配置文件中,然后执行命令
git clone ssh://git@localhost:3001/repo/project.git
然而结果是:
Cloning into 'project'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
所以我不确定我错过了什么。我确实将本地机器生成的密钥添加到了 GitHub,并且能够从那里很好地克隆,所以我很确定这与 Docker 环境中的 Gitea 有关。
我已经验证了 Jenkins 容器可以看到 Gitea 容器并且它们加入了同一个网络。
我在这里缺少什么,以便我可以从在 Docker 中运行的 Gitea 进行 git clone ?我相信这也是解决詹金斯问题的关键。
谢谢