Jenkins Git连接

时间:2017-08-08 19:26:06

标签: git authentication jenkins

在源代码管理部分设置git配置时出现此错误,存储库URL是私有的,如exampleip:/home/project/git-repo/single_login.git而不是来自github

Failed to connect to repository : Command "git ls-remote -h exampleip:/home/project/git-repo/single_login.git HEAD" returned status code 128:
stdout:
stderr: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我尝试在jenkins凭证提供程序中设置用户名和密码,但仍无效。

我在终端中为项目做的克隆就像这个git clone username@exampleip:/home/project/git-repo/single_login.git这个要求密码一旦提供它就可以了

我认为他不知何故以错误的方式输入用户/传递,有人对此有所了解吗?

1 个答案:

答案 0 :(得分:1)

类似scp的ssh网址exampleip:/home/project/git-repo/single_login.git表示运行Jenkins的帐户会查找an ~/.ssh/config file,并带有Host exampleip条目。

Host exampleip
  HostName exampleip.ip
  User username
  IdentityFile /path/to/id_rsa_username

确保id_rsa_username.pub已注册到远程示例服务器~username/.ssh/authorized_keys。然后它会工作。

但是你需要确定谁在运行Jenkins,以便将~/.ssh/config文件设置在正确的位置。