Jenkins与Git存储库的集成

Jenkins与Git存储库的集成,git,jenkins,Git,Jenkins,我已经在centos服务器上安装了git 2.7。并在/srv/repo.git创建了存储库。我可以使用命令ssh://user@serverIP:/srv/repo.git 我已经在Windows 10上的本地计算机上安装了jenkins&git 问题: 与jenkins一起设置git repo时遇到错误。请查看屏幕截图。 错误: Failed to connect to repository : Command "git.exe ls-remote -h -- ssh://

我已经在centos服务器上安装了git 2.7。并在/srv/repo.git创建了存储库。我可以使用命令
ssh://user@serverIP:/srv/repo.git

  • 我已经在Windows 10上的本地计算机上安装了jenkins&git

  • 问题: 与jenkins一起设置git repo时遇到错误。请查看屏幕截图。

  • 错误:

    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.
    

    请帮我做这个。提前感谢。

    您必须将“服务器ip”与服务器的ip交换

    用户名也应该设置为正确的用户名。 你说过你可以像这样克隆

    ssh://user@serverIP:/srv/repo.git
    
    ssh://user@server_ip:/srv/repo.git
    
    但詹金斯正试图这样克隆

    ssh://user@serverIP:/srv/repo.git
    
    ssh://user@server_ip:/srv/repo.git
    

    我找到了这个问题的解决方案..在git服务器上出现了jenkins的身份验证问题。只需使用以下步骤解决问题:

  • 在本地计算机上打开gitbash,并使用以下命令生成公钥/私钥:ssh-keygen
  • 将id\u rsa.pub内容复制到C:\Users\your\u windows\u user\u here.ssh\known\u hosts
  • 在jenkins获得了源代码管理->Git->凭证添加
  • 在Jenkins中选择Kind->SSH Username with private key,直接输入->将文件中生成的私钥粘贴到此处
  • 在Linux服务器上,转到.ssh/authorized\u keys并将C:\Users\your\u windows\u user\u名称粘贴到此处。ssh\id\u rsa.pub文件内容粘贴到此处
  • 在jenkins项目配置中,转到“源代码管理”部分,然后选择git->Repositary url->粘贴此文件ssh://user@serverIP:/srv/repo.git
  • 选择我们在步骤3和步骤4中创建的凭据

  • 您使用的是精确值
    ssh://user@serverIP:/srv/repo.git
    ?或者您是否用您自己的服务器IP地址的值替换th,用repo名称替换
    repo
    ,等等?您能否从本地机器上的终端执行Jenkins发出的命令?逐字逐句。@evolutionxbox。。我正在用正确的值更改用户、服务器ip和repo。您可以试试@YSC的想法吗?@YSC.“执行Jenkins给出的命令”是什么意思。。?詹金斯给出了什么命令?引用OP:“我可以用这个命令克隆这个。”ssh://user@serverIP:/srv/repo.git。“是的,可能是因为无论出于什么原因,OP都可以解析‘serverIP’。但这并不意味着詹金斯也能做到这一点。此外,OP正在做两件不同的事情。他能用计算机克隆*user@serverIP“但詹金斯正在尝试克隆”user@server_ip“那不一样;)@YSC然后OP自相矛盾-只有两种可能性,
    server\u IP
    可以解决也可以不解决。我同意这个问题不好,但这并不能让这个答案变得好。你在做假设,你可以向OP询问精确度,或者将问题标记为低质量。