我无法通过jenkins从Github中提取代码。我确实尝试在jenkins中切换git插件,但它没有用。不知道问题是什么..有些指针对此有帮助.. 我错过了一些插件或ami使用错误版本的插件吗?
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/TestGitCon/workspace
Checkout:workspace / /var/lib/jenkins/jobs/TestGitCon/workspace - hudson.remoting.LocalChannel@37ff3f85
Using strategy: Default
ERROR: Workspace has a .git repository, but it appears to be corrupt.
hudson.plugins.git.GitException: Error performing command: usr/bin/git rev-parse --verify HEAD
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:904)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:858)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:868)
at hudson.plugins.git.GitAPI.validateRevision(GitAPI.java:326)
at hudson.plugins.git.GitAPI.hasGitRepo(GitAPI.java:125)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1005)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1265)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
at hudson.model.Run.execute(Run.java:1759)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: java.io.IOException: Cannot run program "usr/bin/git" (in directory "/var/lib/jenkins/jobs/TestGitCon/workspace"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:803)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$ProcStarter.join(Launcher.java:388)
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:885)
... 18 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)
... 24 more
Cloning the remote Git repository
Cloning repository git@github.com:RosettaCommons/main.git
Error trying to determine the git version: Error performing command: usr/bin/git --version
Assuming 1.6
Fetching upstream changes from git@github.com:RosettaCommons/main.git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway.
hudson.plugins.git.GitException: Error performing command: usr/bin/git fetch -t git@github.com:RosettaCommons/main.git +refs/heads/*:refs/remotes/origin/*
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:904)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:858)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:200)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:1105)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1265)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
at hudson.model.Run.execute(Run.java:1759)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: java.io.IOException: Cannot run program "usr/bin/git" (in directory "/var/lib/jenkins/jobs/TestGitCon/workspace"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:803)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$ProcStarter.join(Launcher.java:388)
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:885)
... 17 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)
... 23 more
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1076)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1265)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
at hudson.model.Run.execute(Run.java:1759)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
答案 0 :(得分:1)
我的git可执行文件的路径是var / lib / jenkins。我在var / lib / jenkins之前添加了一个斜杠,即/ var / lib / jenkins。我还安装了#34; Git pull request builder&#34;插入。我将git插件版本降级为1.1.26。现在我可以通过jenkins从github下载代码。
答案 1 :(得分:1)
我有同样的错误,但是我的原因是不同的。实际上,我已经在shell脚本文件中使用curl命令,然后不得不创建一个Docker映像。 因此,要使Docker映像能够执行curl命令,我必须安装Curl。而且我已经在Docker文件中编写了以下代码
RUN apt-get update && \
apt-get install -y curl && \
但是,当我提交代码时,Jenkins构建失败,并显示相同的消息错误:工作区具有.git存储库,但它似乎已损坏
解决方法是我必须在install curl命令中添加--no-install-recommends
。像这样
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
原因是Ubuntu installs recommended but not suggested packages。因此,Ubuntu试图添加一些不需要的但也许是推荐的程序包,但由于某种原因使该程序无法通过。
答案 2 :(得分:0)
开始检查您在Jenkins设置中为git工具设置的位置(Jenkins - &gt;管理Jenkins - &gt;配置系统)。
参见例如this answer:
看起来Jenkins的GIT配置存在问题,给出了GIT的完整路径而不仅仅是“
git
”
答案 3 :(得分:0)
要解决此问题,请在Jenkins从属服务器(或服务器)中找到一个/jenkins/workspace/<job name>
目录。您应该删除工作空间中的所有文件(如果没有负面影响,请删除 ),或者仅删除.git
目录。
再次执行任务。