git jenkins - 克隆远程 repo 'origin' 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41268071/
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-19 12:30:48  来源:igfitidea点击:

jenkins - Error cloning remote repo 'origin'

gitjenkinsbitbucket

提问by jellyBeans

I have setup Jenkins server running locally on my machine. Configured a Jenkins job to clone BitBucket repository. Also did the following: * Generated SSH-Key initially to connect to BitBucket. Later changed it to clone from HTTPS using username & password which have been configured in the "Credentials" section in Jenkins * Also did an init on the folder where the workspace is created as a result of the Jenkins jobs. In my case it is C:\Jenkins\jobs\\workspace.

我已经设置了在我的机器上本地运行的 Jenkins 服务器。配置了一个 Jenkins 作业来克隆 BitBucket 存储库。还做了以下事情: * 最初生成 SSH-Key 以连接到 BitBucket。后来将其更改为使用用户名和密码从 HTTPS 克隆,这些用户名和密码已在 Jenkins 的“凭据”部分中配置 * 还在由于 Jenkins 作业而创建工作区的文件夹上进行了初始化。就我而言,它是 C:\Jenkins\jobs\\workspace。

Getting the following exception:

得到以下异常:

ERROR: Timeout after 10 minutes
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe     
fetch --tags --progress     
https://<AccountName>@bitbucket.org/<repositoryName>/<projectName>.git 
+refs/heads/*:refs/remotes/origin/*" returned status code -1
:stdout 
:stderr: 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access0(CliGitAPIImpl.java:64)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:315)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:512)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1054)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1720)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
ERROR: null

回答by jellyBeans

I managed to get around this problem. I was definitely sure that it was something to do with the git.exe path and I was correct. When I ran the following command in git bash, it gave a different path for git.exe

我设法解决了这个问题。我绝对确定这与 git.exe 路径有关,而且我是正确的。当我在 git bash 中运行以下命令时,它为 git.exe 提供了不同的路径

$which git
/mingw64/bin/git

In my earlier configuration, I pointed to git.exe in the location /bin/git.

在我之前的配置中,我指向了位置 /bin/git 中的 git.exe。