git - Jenkins 无法从安装在同一台服务器上的 git 存储库中获取,在 box 上成功执行命令

标签 git maven jenkins jenkins-plugins

这是一个奇怪的问题,我们已经尝试了来自 stackoverflow 的可能解决方案,但仍然无法解决。在 SA 的周末补丁和重启后,我们的 jenkins 作业无法构建...

Console output for all projects-

> /usr/bin/git fetch --tags --progress /home/user/repositories/git/user.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from /home/user/
repositories/git/user.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)
    at hudson.scm.SCM.checkout(SCM.java:484)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1270)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(
AbstractBuild.java:609)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.
java:531)
    at hudson.model.Run.execute(Run.java:1717)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:537)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --
tags --progress /home/user/repositories/git/user.git +refs/heads/*:refs/
remotes/origin/*" returned status code 128:
stdout: 
stderr: error: cannot run git-upload-pack '/home/user/repositories/git/user.
git': No such file or directory
fatal: unable to fork
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(
CliGitAPIImpl.java:1591)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.
launchCommandWithCredentials(CliGitAPIImpl.java:1379)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(
CliGitAPIImpl.java:86)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl
.java:324)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:733)
    ... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
  1. git 仓库和 jenkins 在同一台服务器上,不应该使用 ssh。 源代码管理将存储库 URL 配置为/home/user/repositories/git/user.git 所有用户都可以读/写 git 存储库。

  2. 以jenkins身份登录服务器,运行

/usr/bin/git fetch --tags --progress/home/user /repositories/git/user.git +refs/heads/:refs/remotes/origin/

它可以从git仓库中成功获取,没有任何问题。

  1. 升级jenkins到1.600,GIT客户端插件到1.17.1,GIT插件到2.3.5还是不行

  2. 新项目 - 自由式项目 ,gradle工程,Configure System中不指定JDK,build时可以fetch-

    从/home/user/repositories/git/user.git 获取上游更改

    /usr/bin/git --version # timeout=10

    /usr/bin/git fetch --tags --progress /home/user/repositories/git/user.git +refs/heads/:refs/remotes/origin/

    /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10

    /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 Checking out Revision c6223c5c4693dc9be933b9e4b2fa915fea311891 (refs/remotes /origin/master) /usr/bin/git config core.sparsecheckout # timeout=10

    /usr/bin/git checkout -f c6223c5c4693dc9be933b9e4b2fa915fea311891

    /usr/bin/git rev-list 050ac61d242b61ab88f533932820cab4e44db7b7 # timeout= 10 [Gradle] - Launching build. [PROJECT] $ /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/ Main/bin/gradle ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

指定JDK后,jenkins无法从git中获取,同样的错误

  1. 新的 Maven 项目无法运行,同样的错误

  2. 检查新maven项目的工作空间- 里面只有一个“.git”文件夹 分支机构 Hook 信息 对象 引用 配置 156 B View 描述 73 B View FETCH_HEAD 0 B View HEAD 23 B View

检查新的自由风格项目的工作区-

.git
.settings
PROJECT
.gitignore  329 B    view
.project    385 B   
  1. SA 说补丁是针对 unix 核心和 rsyslog 的,似乎与 jenkins 和 git 无关。

关于我们还可以检查什么来解决这个问题有什么建议吗?谢谢!

最佳答案

您可能不应该以这种方式使用共享的可写 Git 存储库。如果您最终得到一些没有共享可写或可执行位的目录,那么其他用户将无法进入它们。

也就是说,这里给出了错误信息:

stderr: error: cannot run git-upload-pack  '/home/user/repositories/git/user.git': No such file or directory

这似乎没有显示为目录,或者 Jenkins 作业无法读取它。在该名称上运行 ls -lR 以查看它是否提供了一个列表,如果是,是否所有目录都具有正确的权限位以允许“其他”读取/写入它们(或者包括 Jenkins 在内的所有用户都在一个合适的组,它是组读/写)。

关于git - Jenkins 无法从安装在同一台服务器上的 git 存储库中获取,在 box 上成功执行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31253059/

相关文章:

java - Arquillian TomEE 测试性能

jenkins - 客户端错误 : HTTP 302 Found, Jenkins 连接到 Gitlab

windows - 配置 Jenkins 以在 Windows 上使用 GIT,得到 stderr : Permission denied (publickey)

git - 混帐错误 : You can only push your own commits in this repository

scala - 当加特林负载测试表现不佳时如何使 Jenkins 工作失败

html - 为什么我对 git 的推送在我的 Bootstrap 模板上不起作用?

scala - 输出路径在同一模块之间共享错误

android - 当我尝试构建 Unity 项目时 Jenkins 被绞死

android - 如何在一个 git repo 中管理多个相关的 Android 项目

git checkout 版本,包括子模块