windows Jenkins 错误克隆远程 repo 'origin',从属节点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29301729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:01:12  来源:igfitidea点击:

Jenkins Error cloning remote repo 'origin', slave node

windowsgithubjenkinsslave

提问by Nicolas Amabile

I need some help here, It's been a week I'm with this problem, can't figure out what's going on. I'm not able to clone a git repo from a slave node (Jenkins). I added the ssh key, host and slave (I've already tried generating a single key and one for each virtual and host)).

我在这里需要一些帮助,我遇到这个问题已经一周了,无法弄清楚发生了什么。我无法从从属节点 (Jenkins) 克隆 git repo。我添加了 ssh 密钥、主机和从设备(我已经尝试为每个虚拟和主机生成一个密钥和一个))。

On Jenkins:

关于詹金斯:

  • url:[email protected]: < repo>
  • Credentials: Here I tried with username/password, username with ssh file, username with ssh key directly, and -none-.
  • url:[email protected]: <repo>
  • 凭据:这里我尝试使用用户名/密码,用户名与 ssh 文件,用户名与 ssh 密钥,以及 -none-。

It doesn't seems like there is an authentication problem since I can clone the repo manually from console (both, slave and host). I can also connect with

似乎没有身份验证问题,因为我可以从控制台(从属和主机)手动克隆 repo。我也可以连接

ssh -T [email protected]

ssh -T [email protected]

so the ssh key is fine, but when I build, this appear on console:

所以 ssh 密钥很好,但是当我构建时,它出现在控制台上:

Building remotely on IE10Win7 in workspace C:\Users\IEUser\Desktop\< folder >

Wiping out workspace first.

Cloning the remote Git repository

Cloning repository [email protected]:< repo>.git

git init C:\Users\IEUser\Desktop\< folder> # timeout=10

ERROR: Error cloning remote repo 'origin'

ERROR: Error cloning remote repo 'origin'

Performing Post build task...

在工作区 C:\Users\IEUser\Desktop\< 文件夹 > 中的 IE10Win7 上远程构建

首先清除工作空间。

克隆远程 Git 存储库

克隆仓库 [email protected]:<repo>.git

git init C:\Users\IEUser\Desktop\<文件夹> # timeout=10

错误:克隆远程 repo 'origin' 时出错

错误:克隆远程 repo 'origin' 时出错

正在执行构建后任务...

Does anyone have an idea? Hope someone can give me a clue, Thanks!

有没有人有想法?希望有人能指点迷津,谢谢!

回答by starlying

I fixed this problem by setting the slave node tool path, selecting git and setting its value to

我通过设置从节点工具路径,选择 git 并将其值设置为

C:\Program Files (x86)\Git\bin\git.exe

Location: Configure Node - Tool Locations

位置:配置节点 - 工具位置

回答by dhj

I recently updated several jenkins plugins and had this problem after the updates. Rolling back the git plugin didn't help, but I did a few other things to get it working. I listed all three here, but it was probably (2) that fixed the problem. Apparently the git executable was reset to default. So, configuring the git executable within the specific project was probably all that was needed. However the other items might come in handy too.

我最近更新了几个 jenkins 插件,更新后遇到了这个问题。回滚 git 插件没有帮助,但我做了一些其他的事情来让它工作。我在这里列出了所有三个,但可能是 (2) 解决了问题。显然 git 可执行文件已重置为默认值。因此,可能只需要在特定项目中配置 git 可执行文件即可。然而,其他项目也可能派上用场。

(1) The default git on a jenkins linux install geenrally points to /usr/lib... You need to specify a separate GitForWindows that points to the windows version:

(1) jenkins linux install 上的默认git一般指向/usr/lib... 需要单独指定一个指向windows版本的GitForWindows:

Manage Jenkins
Configure System
Under Git - Git Installations
    Add Git -> Git
    Give it a name to be referenced in projects
      (mine is WindowsGit)
    Set Path to Git Executable
      (mine is "C:\Program Files (x86)\Git\bin\git.exe")
      (for recent git the path is "C:\Program Files\Git\bin\git.exe")

(2) Configure git on the specific project:

(2)在具体项目上配置git:

Select the project
Select Configure
Under Source Code Management - Git
    Select Git Executable as configured in 1)
    Set credentials or add new (ssh keys, etc)

(3) Updating the jenkins slave service to run as a specific user:

(3)更新jenkins slave服务以特定用户身份运行:

Go to Windows Services on the slave -- StartMenu, type "services"
Select the Jenkins Slave service in the list on the right
Right-click and select "Properties" of the Jenkins Slave service
Select the "Log On" tab
Update the username and password used in manual tests
    Domain login can be specificied with <DOMAIN>\<USERNAME>
    Local logins just use <USERNAME>
OK to save and exit
Right-click again and select "Restart" to make the changes active.

回答by Sir Jane

I found a decent workaround in my case. The git clonecommand always inherits its process owner, which may make a difference, even if the two owners of Jenkins (SYSTEM) and cmd (USER) seem to have the same rights on your system. All other configurations were identical (keys, knownhosts, Git client version).

在我的情况下,我找到了一个不错的解决方法。该git clone命令始终继承其进程所有者,这可能会有所不同,即使 Jenkins (SYSTEM) 和 cmd (USER) 的两个所有者在您的系统上似乎具有相同的权限。所有其他配置都相同(密钥、已知主机、Git 客户端版本)。

So as far as I can see, calling git clonefrom cmd will succeed because it calls the remote as USER, whereas git clonecalled from Jenkins may be rejected because it calls the remote as SYSTEM. In Services, where you would typically start Jenkins through the GUI, you can configure the service to run as a different user (right click on service --> Properties --> Log On). I had to put it like USER@DOMAIN, e.g. [email protected] or so. I'm not sure about how a cmd parameter would look, but I'd expect there to be one.

因此,据我所知,git clone从 cmd调用会成功,因为它将远程调用为 USER,而git clone从 Jenkins 调用可能会被拒绝,因为它将远程调用为 SYSTEM。在服务中,您通常会通过 GUI 启动 Jenkins,您可以将服务配置为以不同用户身份运行(右键单击服务 --> 属性 --> 登录)。我不得不把它像 USER@DOMAIN 一样,例如 [email protected] 左右。我不确定 cmd 参数的外观,但我希望会有一个。

Also, I don't quite know what difference this workaround makes in the end, because on my Jenkins, SYSTEM and USER are configured to have the same rights across the system and they are of course both recognized as "Jenkins" by remote. Still, it does the trick for me. Deeper insights welcome.

另外,我不太清楚这种解决方法最终会带来什么不同,因为在我的 Jenkins 上,SYSTEM 和 USER 被配置为在整个系统中拥有相同的权限,当然它们都被远程识别为“Jenkins”。不过,它对我有用。欢迎更深入的见解。

回答by sttaq

I was facing similar problem and found that I need to add git to my PATH environment variable for a Windows based slave. I think that @dhj suggestion 2 might work as well in this case.

我遇到了类似的问题,发现我需要将 git 添加到基于 Windows 的从站的 PATH 环境变量中。我认为 @dhj 建议 2 在这种情况下也可能有效。

I found this workaround on Jenkins Jira.

我在Jenkins Jira上找到了这个解决方法

回答by Nick Jones

In my case, I started getting this exact error after updating Git on someof my build machines (via Chocolatey, using the "git.install" package) from 1.9.4 to 2.5.0. The old 1.9.4 install was a 32-bit package but the new one is a 64-bit one, so the default install location switched from C:\Program Files (x86)\Git to C:\Program Files\Git. I had the 64-bit path configured on the Jenkins master (since it had the newer Git version), but some slaves still had the older 32-bit version installed, so the slaves were attempting to use an incorrect path. I could have overridden the Git path for individual slaves but the cleaner solution for me was simply to upgrade all the slaves to the newer 64-bit version.

就我而言,在我的一些构建机器上(通过 Chocolatey,使用“git.install”包)从 1.9.4 更新到 2.5.0后,我开始收到这个确切的错误。旧的 1.9.4 安装是 32 位软件包,但新安装的是 64 位软件包,因此默认安装位置从 C:\Program Files (x86)\Git 切换到 C:\Program Files\Git。我在 Jenkins master 上配置了 64 位路径(因为它有更新的 Git 版本),但一些从站仍然安装了旧的 32 位版本,所以从站试图使用不正确的路径。我可以覆盖单个从属设备的 Git 路径,但对我来说更简洁的解决方案只是将所有从属设备升级到较新的 64 位版本。

回答by Trev M

I tried most of the above:

我尝试了以上大部分内容:

Specify git location. Set service user. Run as Administrator.

指定 git 位置。设置服务用户。以管理员身份运行。

None of it worked. Eventually decided to uninstall git64 and install git32... changed the git path to the new location (in x86 Program Files). And everything worked.

它都没有奏效。最终决定卸载 git64 并安装 git32... 将 git 路径更改为新位置(在 x86 程序文件中)。一切都奏效了。

回答by Chris Giddings

I ran into this issue recently.

我最近遇到了这个问题。

We had some items in our PATH EV which we had added when trying to connect Winium and Selenium to our Jenkins instance.

我们的 PATH EV 中有一些项目是我们在尝试将 Winium 和 Selenium 连接到我们的 Jenkins 实例时添加的。

We removed these items, but still Jenkins seemed to be holding on to the values. After a bit of troubleshooting: restarting Jenkins; restarting the Jenkins server; setting the EVs at the node level; etc., we restarted the Jenkins JNLP service on the Windows slave.

我们删除了这些项目,但 Jenkins 似乎仍然坚持这些价值观。经过一番排查:重启Jenkins;重启 Jenkins 服务器;在节点级别设置 EV;等等,我们在 Windows slave 上重启了 Jenkins JNLP 服务

And they lived happily ever after.

从此他们过着幸福的生活。

回答by Naren Chejara

I also got the same error and fixed by adding a git path in the "Manage Jenkins -> Global Tool Configuration".

我也遇到了同样的错误,并通过在“管理 Jenkins -> 全局工具配置”中添加一个 git 路径来修复。

In my env, The windows Jenkins master run a job on the ubuntu slave machine, the master machine has used the default git ('C:\Program Files\Git\git.exe') path and the slave machine has used the git ('/usr/bin/git') path, therefore, I configured slave git path into the master configuration '/usr/bin/git' and its start working for me

在我的环境中,windows Jenkins master在ubuntu slave机器上运行了一个job,master使用了默认的git('C:\Program Files\Git\git.exe')路径,slave使用了git( '/usr/bin/git') 路径,因此,我将从属 git 路径配置为主配置 '/usr/bin/git' 并开始对我来说有效