git 使用 refspec 参数获取结果为空响应
git fetch with refspec parameter results in empty response
我在 jenkins 中使用 git 插件时遇到问题。
詹金斯:1.617
git: 1.9.5.msysgit.1
OS: windows 服务器 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 [<options>] [<repository> [<refspec>…]]
) 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 存储库:
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 中的一个错误,已在 unix/linux 环境中修复,但未在 windows 中修复:
https://issues.jenkins-ci.org/browse/JENKINS-20879
我从 id_rsa 密钥文件中删除了密码(在正确的 /.ssh/ 目录中)
$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
我在 jenkins 中使用 git 插件时遇到问题。
詹金斯:1.617
git: 1.9.5.msysgit.1
OS: windows 服务器 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 [<options>] [<repository> [<refspec>…]]
) 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 存储库:
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 中的一个错误,已在 unix/linux 环境中修复,但未在 windows 中修复: https://issues.jenkins-ci.org/browse/JENKINS-20879
我从 id_rsa 密钥文件中删除了密码(在正确的 /.ssh/ 目录中)
$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]