为什么Jenkins的Git插件用额外的斜杠重写我的本地git repo url?

问题描述 投票:2回答:4

我现在正在尝试设置一个Jenkins作业(在一台Windows服务器上)来监视位于Gitosis服务器上的内部Git仓库(在不同的Windows服务器上)。

网址如下所示:ssh://[email protected]:relative_path / repo.git(为安全性而替换实际值,相对路径也不适用于'〜/',它只能在没有前导的情况下工作'/ “)。

当使用url从命令行运行git clone时,一切都很顺利。

在Jenkins作业中配置Git SCM时,它能够运行ls-remote命令(这确认为Jenkins实例正确配置了ssh密钥)。

但是,当作业执行时,url似乎会被另外的正斜杠重写,导致clone命令失败。

Started by user Meh
[EnvInject] - Loading node environment variables.
Building in workspace D:\local_repo_test
 > git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url ssh:///[email protected]:relative_path/repo.git # timeout=10
Fetching upstream changes from ssh:///[email protected]:relative_path/repo.git
 > git.exe --version # timeout=10
 > git.exe -c core.askpass=true fetch --tags --progress ssh:///[email protected]:relative_path/repo.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

困扰我的是'///'。有没有人见过这样的东西?

任何有关这方面的帮助将不胜感激。

git ssh jenkins cygwin gitosis
4个回答
2
投票

据我所知,通过检查各种版本的git,你使用ssh协议的相对路径语法是不明确的。它被解释为你希望Windows上的msysgit版本,但不是我测试过的任何其他平台。

当我测试

  • git 1.7.1,CentOS 6.6,git clone ssh://mwaite@mark-pc1:bin/失败并报告ssh: Could not resolve hostname mark-pc1:bin: Name or service not known
  • git 1.7.2.5,Debian 6,git clone ssh://mwaite@mark-pc1:bin/失败并报告ssh: Could not resolve hostname mark-pc1:bin: Name or service not known
  • git 1.7.10.4,Debian 7,git clone ssh://mwaite@mark-pc1:bin/失败并报告ssh: Could not resolve hostname mark-pc1:bin: Name or service not known
  • git 2.1.4,Debian测试,git clone ssh://mwaite@mark-pc1:bin/失败并报告fatal: '/' does not appear to be a git repository
  • git 2.2.1,Ubuntu 14.04,git clone ssh://mwaite@mark-pc1:bin/失败并报告“致命:'/'似乎不是一个git存储库”
  • git 2.3.0,Ubuntu 14.04,git clone ssh://mwaite@mark-pc1:ssh/home/mwaite/bin成功并使用ssh协议克隆来自/ home / mwaite / bin的repo

据我所知,如果冒号后的第一个单词是协议(如ssh)或端口号(如22),那么它将被解释为用于存储库访问的服务或端口号。

我在JENKINS-26680JENKINS-27483中进一步描述了一些细节


1
投票

由于我无法对Jenkins人提出任何牵引力,试图解决为什么网址被'///'改写,我也无法确定Gitosis是否有任何问题我想出了一个解决方法。

由于已经安装并运行了Cygwin,SSH和Gitosis,我决定在机器上添加一个新用户并通过它运行所有git ssh命令。

按照此处的步骤添加新用户http://techtorials.me/cygwin/create-and-add-users/

然后我chmod'ed和chgrp'ed / home / git / reposotories到sshUsers组。一旦到位,我就可以使用带有绝对路径名的Git SSH URL绕过jenkins的'///'url问题。


0
投票

这是一个远景,但只是为了检查 - 你可能在路径中使用参数?类似$ PROTOCOL / $ URL / $ PATH和PROTOCOL ='ssh://'?听起来很牵强,所以没有冒犯的意思。但我曾经做过类似的事情,参数化使我无法看到该字段实际上发送了一个比它应该更多的斜杠。


0
投票

使用Jenkins和我想要通过ssh克隆的私有bitbucket存储库时,我遇到了同样的问题。正如Mark Waite在答案中所提到的,这被一些人认为是一个错误。然而,还有其他人认为这是预期的行为,因为'相对URI'不支持JENKINS-26327

在我的情况下工作的临时解决方法是添加端口号22.所以在Jenkins管道中我替换了

url: 'ssh://[email protected]:/my_team/my_repo.git'

url: 'ssh://[email protected]:22/my_team/my_repo.git'

现在管道按预期运行。

© www.soinside.com 2019 - 2024. All rights reserved.