git 错误:克隆远程 repo 'origin' 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37155321/
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
ERROR: Error cloning remote repo 'origin'
提问by Learner
Tried with the configure option, not able to find the tools configuration option and the git executable section. Seems like it occurs after a successful build only. Please help.
尝试了配置选项,找不到工具配置选项和 git 可执行部分。似乎它只发生在成功构建之后。请帮忙。
Here's the output I receive after building the project on the console output section:
这是我在控制台输出部分构建项目后收到的输出:
Building in workspace C:\Users\Anishas\.jenkins\workspace\Sample123
Cloning the remote Git repository
Cloning repository https://github.com/AnishaSalunkhe/HelloWorld.git
> C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123 # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init C:\Users\Anishas\.jenkins\workspace\Sample123
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:656)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:463)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1057)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Error performing command: C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1726)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1695)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1691)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1321)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:654)
... 12 more
Caused by: java.io.IOException: Cannot run program "C:\Users\Anishas\git" (in directory "C:\Users\Anishas\.jenkins\workspace\Sample123"): CreateProcess error=5, Access is denied
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:240)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1715)
... 16 more
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 22 more
ERROR: null
Finished: FAILURE
回答by Ed of the Mountain
This wasted so much timeon my Jenkins Windows slave.
这在我的 Jenkins Windows 奴隶上浪费了很多时间。
I knew git was in the path because I executed "where git" in the build job's batch command.
我知道 git 在路径中,因为我在构建作业的批处理命令中执行了“where git”。
where git
C:\Program Files (x86)\Git\cmd\git.exe
Apparently the Jenkins Git Pluginexecutes ** before ** the environment is inherited.
显然Jenkins Git 插件在 ** 环境被继承之前执行 **。
SET YOUR SLAVE's PATH to Git ( Just DO IT !! )
设置你的奴隶到 Git 的路径(就去做吧!!)
1) Go to your Windows slave configuration Manage Jenkins > Manage Nodes
1) 转到您的 Windows 从属配置管理 Jenkins > 管理节点
2) Select your slave configuration
2) 选择您的从站配置
3) Check Tool Locationsunder Node Properties
3) 检查节点属性下的工具位置
4) Enter complete path to git executable including git.exe
4) 输入包含 git.exe 的 git 可执行文件的完整路径
[x] Tool Locations
Name: (GIT) git
Home: C:\Program Files (x86)\Git\cmd\git.exe
See screenshot:
看截图:
回答by Chandra Pal
回答by Learner
set the path to git.exe and not only to the directory of the git file in both the locations of tool configurations.
将路径设置为 git.exe 而不仅仅是工具配置的两个位置的 git 文件目录。
回答by Kamini Naithani
Sometimes this error occurs when disk space is less. so do check the space of your machine where jenkins is hosted. :)
有时当磁盘空间较少时会发生此错误。因此,请务必检查托管 jenkins 的机器的空间。:)
回答by Genki
If anyone is using Jenkins with freshly installed Xcode, you'll need to agree to the license using sudo xcodebuild -license
or agree through UI.
如果有人在新安装的 Xcode 上使用 Jenkins,您需要同意使用许可sudo xcodebuild -license
或通过 UI 同意。
回答by shafi
Windows: 1. Install git in windows machine 2. The git.exe path is C:\Program Files\Git\cmd\git.exe (by default, unless you change during installation) 3.Now need to show the path of git.exe in Jenkins git plugin tool
Windows: 1.在windows机器上安装git 2.git.exe路径为C:\Program Files\Git\cmd\git.exe(默认情况下,除非你在安装过程中更改) 3.现在需要显示git的路径Jenkins git 插件工具中的 .exe
a)manage Jenkins>Global Tool Configuration>Git
a)管理Jenkins>全局工具配置>Git
b)Add git : name: anything and Path:C:\Program Files\Git\cmd\git.exe 4. Then build for clone. Should be ok
b) 添加 git : name: any 和 Path:C:\Program Files\Git\cmd\git.exe 4. 然后构建克隆。应该可以
Linux CentOS7: Same error message I got and after installation git in same machine were Jenkins installed, it is solved.
Linux CentOS7:我得到了同样的错误信息,在同一台机器上安装了 git 后,Jenkins 被安装,它解决了。
yum install git
yum 安装 git
回答by Azeem
1) Make sure the git.exe has executable permissions. 2) Make sure git is configured correctly to refer in Global Tool configurations and also on the Jenkins agent (windows in your case) where you running the job, environment variable for git.exe executable is set correctly
1) 确保 git.exe 具有可执行权限。2) 确保 git 已正确配置为在全局工具配置中以及在运行作业的 Jenkins 代理(在您的情况下为 windows)中引用,git.exe 可执行文件的环境变量设置正确
回答by Nikunj
Then you need to follow below steps. Hope so this may be useful for you to resolve your problem.
然后您需要按照以下步骤操作。希望这可能对您解决问题有用。
If your master is linux machine and slave is windows machine...
如果你的主人是 linux 机器而奴隶是 windows 机器......
Pre-Requisites:
先决条件:
- your slave machine should have same java version(jdk 1.8).
- Git should be installed on your slave machine.
- 你的从机应该有相同的 java 版本(jdk 1.8)。
- Git 应该安装在你的从机上。
Steps to follow:
要遵循的步骤:
Go to your Windows slave configuration Manage Jenkins > Manage Nodes
Select your slave configuration
Check Tool Locationsunder Node Properties
Enter complete path to git executable including
git.exe
转到您的 Windows 从属配置管理 Jenkins > 管理节点
选择您的从站配置
检查节点属性下的工具位置
输入 git 可执行文件的完整路径,包括
git.exe
Tool Locations
Name: (GIT) git
Home: C:\Program Files (x86)\Git\cmd\git.exe
回答by Chitralekha Sawant
Don't forget to Add your deploy key credentials (the deploy key attached to the github project) in jenkins (http://yourjenkinsurl:8080/credentials/)
不要忘记在 jenkins ( http://yourjenkinsurl:8080/credentials/) 中添加您的部署密钥凭据(附加到 github 项目的部署密钥)