2
votes

This is a weird issue and we've tried possible solutions from stackoverflow yet still cannot solve it. After SA's weekend patch and reboot, our jenkins job cannot build...

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 repository and jenkins are on the same server, ssh should not be used. Source Code Management has Repository URL configged as /home/user/repositories/git/user.git git repository is read/writable by all users.

  2. login server as jenkins, run

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

It can fetch successfully from the git repository without any problem.

  1. Upgrade jenkins to 1.600, GIT client plugin to 1.17.1, GIT Plugin to 2.3.5 still doesn't work

  2. New Item - Freestyle project , gradle project, not specify JDK in Configure System, can fetch when build-

    Fetching upstream changes from /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.

After specify JDK, jenkins cannot fetch from git, same error

  1. New Maven project cannot work, same error

  2. Check the workspace of new maven project- There is only a ".git" folder, within that branches hooks info objects refs config 156 B view description 73 B view FETCH_HEAD 0 B view HEAD 23 B view

Check the workspace of new free style project-

.git
.settings
PROJECT
.gitignore  329 B    view
.project    385 B   
  1. SA said the patching is for unix core and rsyslog, with seems irrelevant to jenkins and git.

Any suggestions on what else we can check to get this solved? Thanks!

2
What is the user running the Jenkins instance? And what user was logged in at the time that it was started back up? I had noticed a similar problem months ago where on the Windows machine (I notice this is a different platform to your case, but decided to share anyways) Jenkins slave I had logged in as my own user (opposed to the slave account) and started the service -- as a result, environment variables were comprised and caused numerous issues.Anthony Forloney
jenkins is run by "jenkins"-jenkins 5354 1 14 13:45 ? 00:28:00 /opt/jdk/1.7.0_55l64/bin/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --httpPort=8080 --ajp13Port=8009 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 git is under another user--# grep jenkins /etc/passwd jenkins:x:498:499:Jenkins Continuous Build server:/var/lib/jenkins:/bin/falseamb11144

2 Answers

0
votes

You probably shouldn't be using a shared writable Git repo in this way. If you've ended up with some directories without the shared writable or executable bit then other users won't be able to go into them.

That said, the error message is given here:

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

It looks like this isn't showing up as a directory, or the Jenkins job can't read it. Run ls -lR on that name to see if it comes up with a list, and if so, whether all directories have the correct permissions bits to allow 'other' to read/write to them (or that all your users including Jenkins are in a suitable group and it is group read/write).

0
votes

I had this same problem and it was caused by Jenkins plugin EnvInject. After I removed that plugin, everything started to work. It is a mystery to me why configuration of JDK messed things up, but definitively the root cause was EnvInject itself.

Another issue I had was that I didn't have properly configured git binary: Manage Jenkins -> Configure System -> Git -> Path to Git executable. After I changed the value to absolute location of git (/usr/bin/git), everything started to work.