无法在Jenkins中克隆本地git存储库

时间:2016-10-13 07:50:47

标签: git jenkins

我无法使用jenkins git插件在本地系统中克隆git repostory。我收到以下错误。起初,我认为这是一个特权问题。但是,在更改了jenkins的用户之后,我也遇到了同样的错误。以下是我从jenkins获得的控制台输出:

Started by user Shibi
Building in workspace /var/lib/jenkins/workspace/AMS-CLOUD
Cloning the remote Git repository
Cloning repository https://github.com/Atlonainc/AMS-Source-Code.git
git init /var/lib/jenkins/workspace/AMS-CLOUD # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /var/lib/jenkins/workspace/AMS-CLOUD
at   org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:663)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:464)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1042)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1082)
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.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:401)
Caused by: hudson.plugins.git.GitException: Error performing command:    git init /var/lib/jenkins/workspace/AMS-CLOUD
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1759)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1725)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1721)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1391)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:661)... 12 more
Caused by: java.io.IOException: Cannot run program "git" (in directory "/var/lib/jenkins/workspace/AMS-CLOUD"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at hudson.Proc$LocalProc.<init>(Proc.java:243)
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:1748)
... 16 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 21 more``
ERROR: null
Finished: FAILURE

请有人帮我解决这个问题。

1 个答案:

答案 0 :(得分:2)

转到Manage Jenkins -> Global Tool Configuration并在Git下放入完整路径(例如:/usr/local/bin/git)到系统上的git可执行文件:

enter image description here

默认情况下,Path to Git executable假定git位于PATH上。从您帖子中的错误来看,似乎不是这种情况,因为找不到git可执行文件:

Caused by: java.io.IOException: Cannot run program "git" (in directory "/var/lib/jenkins/workspace/AMS-CLOUD"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)

Caused by: java.io.IOException: error=2, No such file or directory