git - Jenkins 与 Git 存储库的集成
问题描述
我在我的 centos 服务器上安装了 git 2.7。并在 /srv/repo.git 创建了存储库。我可以使用命令克隆它
ssh://user@serverIP:/srv/repo.git
。我已经在 Windows 10 的本地机器上安装了 jenkins & git。
错误:
Failed to connect to repository : Command "git.exe ls-remote -h -- ssh://username@server_ip:/srv/repo.git HEAD" returned status code 128:
stdout:
stderr: ssh: Could not resolve hostname server_ip: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
请帮助我。提前致谢。
解决方案
我找到了这个问题的解决方案..有一个使用 git 服务器对詹金斯进行身份验证的问题。只需使用以下步骤解决:
- 在本地机器上打开 git bash 并使用命令生成公钥/私钥:ssh-keygen
- 将 id_rsa.pub 内容复制到 C:\Users\your_windows_user_name here.ssh\known_hosts
- 在詹金斯得到源代码管理-> Git->凭据添加
- 在 Jenkins 中选择 Kind->SSH Username with private key,直接输入 -> 从文件中将生成的私钥粘贴到此处
- 在 Linux 服务器上转到 .ssh/authorized_keys 并将 C:\Users\your_windows_user_name here.ssh\id_rsa.pub 文件内容粘贴到此处
- 在 jenkins 项目配置中,转到“源代码管理”部分并选择 git->Repository url-> 粘贴此 ssh://user@serverIP:/srv/repo.git
- 选择我们在步骤号中创建的凭据。3 和 4。
推荐阅读
- php - 如何重写标签
- sqlite - 如何在设计时 Firedac 中设置表字段主要?
- python - 来自熊猫数据框的信息矩阵
- c++ - 在 const 函数中的非常量成员上调用非常量函数
- apache-kafka - 如何在Kafka中按键标记消息以删除?
- react-native - 另一个视图中的滚动视图在本机反应中不起作用
- html - Ionic 4 动态照片网址不起作用 - 未显示图像
- mysql - 从当前状态查询中获取总计数
- gitlab - Gitlab CI管道-仅在特定条件下继续下一个阶段
- javascript - Google Maps API v3 map.fitbounds(bounds) 设置地图缩放不正确的问题