带有refspec参数的git fetch导致响应为空
我在jenkins使用git插件时遇到问题 詹金斯:1.617带有refspec参数的git fetch导致响应为空,git,jenkins,Git,Jenkins,我在jenkins使用git插件时遇到问题 詹金斯:1.617 吉特:1.9.5.msysgit.1 操作系统:windows server 2012 jenkins作业的控制台输出为: Building in workspace C:\Program Files (x86)\Jenkins\jobs\Test\workspace > git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from th
吉特:1.9.5.msysgit.1
操作系统:windows server 2012 jenkins作业的控制台输出为:
Building in workspace C:\Program Files (x86)\Jenkins\jobs\Test\workspace
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url ssh://git@localhost:22/projects/DW.git # timeout=10
Fetching upstream changes from ssh://git@localhost:22/projects/DW.git
> git.exe --version # timeout=10
using GIT_SSH to set credentials
> git.exe -c core.askpass=true fetch --tags --progress ssh://git@localhost:22/projects/DW.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
根据Jenkins控制台输出,我检查了windows控制台中git.exe的行为:
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>git.exe -c core.askpass=true
fetch --tags --progress ssh://git@localhost:22/projects/DW.git +re
fs/heads/*:refs/remotes/origin/*
Enter passphrase for key '/.ssh/id_rsa':
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>
但是,在终端中执行命令时,如果没有refspec参数(git fetch[][…]]
),git将按预期响应:
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>git.exe -c core.askpass=true
fetch --tags --progress ssh://git@localhost:22/projects/DW.git
Enter passphrase for key '/.ssh/id_rsa':
From ssh://localhost:22/projects/DW
* branch HEAD -> FETCH_HEAD
为了检查另一个存储库如何响应,我使用了GitHub repo:
C:\gittest>git.exe -c core.askpass=true fetch --tags --progress https://github.
om/skeeto/sample-java-project.git +refs/heads/*:refs/remotes/origin/*
remote: Counting objects: 423, done.
rReceiving oemote: Total 423 (delta 0), reused 0 (delta 0), pabjects: 77% (326
Receiving obj
Receiving objects: 100% (423/423), 64.84 KiB | 0 bytes/s, done.
Resolving deltas: 100% (162/162), done.
From https://github.com/skeeto/sample-java-project
* [new branch] lwjgl -> origin/lwjgl
* [new branch] lwjgl-cube -> origin/lwjgl-cube
* [new branch] lwjgl-lib -> origin/lwjgl-lib
* [new branch] master -> origin/master
* [new branch] minimal -> origin/minimal
* [new branch] noise -> origin/noise
* [new branch] servlet -> origin/servlet
此外,我还使用以下命令检查了远程目录:
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>git remote
origin
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>git remote -v
origin ssh://git@localhost:22/projects/DW.git (fetch)
origin ssh://git@localhost:22/projects/DW.git (push)
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>git branch -r
origin/master
C:\Program Files (x86)\Jenkins\jobs\Test\workspace>git ls-remote
Enter passphrase for key '/.ssh/id_rsa':
From ssh://git@localhost:22/projects/DW.git
a41ca12aa99d2764ff397e7b452ac1e6b2607735 HEAD
a41ca12aa99d2764ff397e7b452ac1e6b2607735 refs/heads/master
我找到了解决办法:
这似乎是jenkins中的一个bug,已在unix/linux环境中修复,但在windows中未修复:
我从id_rsa密钥文件(在右边的/.ssh/目录中)中删除了密码短语
$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]